Skip to content

Commit

Permalink
Keep proper rendering of html content by omitting Content-Type in res…
Browse files Browse the repository at this point in the history
…ponse
  • Loading branch information
tribal-tec committed Nov 15, 2016
1 parent 73fd0c7 commit 7eb2a34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 2 additions & 4 deletions tests/http/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ HTTPClient::response _buildResponse( const std::string& body = std::string( ))
{
response.add_header( std::make_pair( "Content-Length",
std::to_string( body.size( ))));
response.add_header( std::make_pair( "Content-Type",
"application/json" ));
}
response.body( body );
return response;
Expand Down Expand Up @@ -174,10 +172,10 @@ class Client : private HTTPClient
response = get( request_ );
break;
case Method::POST:
response = post( request_, data, std::string( "application/json" ));
response = post( request_, data );
break;
case Method::PUT:
response = put( request_, data, std::string( "application/json" ));
response = put( request_, data );
break;
}

Expand Down
8 changes: 2 additions & 6 deletions zeroeq/http/requestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,13 @@ class RequestHandler
response.status = httpRequest.status;
response.content = httpRequest.reply;

// don't use stock_reply() here as we need a different Content-Type
// don't use stock_reply() here as we do not want to imply a content
// type yet
HTTPServer::response_header contentLength;
contentLength.name = "Content-Length";
contentLength.value = std::to_string( httpRequest.reply.length());

HTTPServer::response_header contentType;
contentType.name = "Content-Type";
contentType.value = "application/json";

response.headers.push_back( contentLength );
response.headers.push_back( contentType );
_addCorsHeaders( response );
}

Expand Down

0 comments on commit 7eb2a34

Please sign in to comment.