Skip to content

Commit

Permalink
Fix Contet-type handling int POST method
Browse files Browse the repository at this point in the history
Content-Type header can have parameters like charset
i.e: Content-Type: text/html; charset=utf-8
**Note**: header.getValue() **returns** "text/html; charset=utf-8"
  • Loading branch information
relu91 committed Apr 10, 2018
1 parent 7418758 commit 0b03369
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ protected Request parse(HttpAsyncExchange exchange) {
throw new SPARQL11ProtocolException(HttpStatus.SC_BAD_REQUEST, "Content-Type is missing");
}

if (headers[0].getValue().equals("application/sparql-update")) {
// Content-Type header can have parameters like charset
// i.e: Content-Type: text/html; charset=utf-8
// Note: header.getValue() returns text/html; charset=utf-8
// TODO: handle charset
String contentType = headers[0].getElements()[0].getName();

if (contentType.equals("application/sparql-update")) {
logger.debug("update via POST directly");

return new UpdateRequest(body);
} else if (headers[0].getValue().equals("application/x-www-form-urlencoded")) {
} else if (contentType.equals("application/x-www-form-urlencoded")) {
try {
Map<String,String> params = HttpUtilities.splitQuery(body);

Expand Down

0 comments on commit 0b03369

Please sign in to comment.