HTTPServerConnection issue?

A general discussion forum.
Posts: 1
Joined: 22 Jul 2014, 17:09

HTTPServerConnection issue?

Postby asjoblom » 22 Jul 2014, 22:15

I noticed some bad request data was coming in for a request and messing up the header data. This was traced down to a request handler that didn't read the form data from the request stream.

Should there be some guards in HTTPServerConnection to ensure that all the data has been read from the socket (belonging to the request). What happened is that the connection was keepAlive and the next request was getting this data instead. This can happen also if data is posted and no request handler is found. The default sendErrorResponce doesn't read the input stream so the next request will get this instead.

Something like this (available is a method I added to HTTPFixedLengthIOS for testing):

std::auto_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
if (pHandler.get())
if (request.expectContinue())

pHandler->handleRequest(request, response);
session.setKeepAlive(_pParams->getKeepAlive() && response.getKeepAlive() && session.canKeepAlive());

// Flush any data not read from the stream, otherwise the next
// request will get this data if keepAlive is used.
HTTPFixedLengthInputStream *fixedStream= dynamic_cast<HTTPFixedLengthInputStream *>(&;
if (session.getKeepAlive() && request.hasContentLength() && fixedStream)

else sendErrorResponse(session, HTTPResponse::HTTP_NOT_IMPLEMENTED);


Posts: 1375
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: HTTPServerConnection issue?

Postby alex » 01 Aug 2014, 02:56

please write a testcase and send this as a github pull request

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest