improved HTTP server handling of errors while reading header

This commit is contained in:
Guenter Obiltschnig 2014-09-25 14:12:21 +02:00
parent 2e657d2a61
commit cc52a8a3db
2 changed files with 9 additions and 0 deletions

View File

@ -209,6 +209,7 @@ void HTTPRequest::read(std::istream& istr)
uri.reserve(64);
version.reserve(16);
int ch = istr.get();
if (istr.bad()) throw NetException("Error reading HTTP request header");
if (ch == eof) throw NoMessageException();
while (Poco::Ascii::isSpace(ch)) ch = istr.get();
if (ch == eof) throw MessageException("No HTTP request header");

View File

@ -113,6 +113,14 @@ void HTTPServerConnection::run()
{
sendErrorResponse(session, HTTPResponse::HTTP_BAD_REQUEST);
}
catch (Poco::Exception&)
{
if (session.networkException())
{
session.networkException()->rethrow();
}
else throw;
}
}
}