diff options
Diffstat (limited to 'lib/httpserver/HTTPServer.cpp')
-rw-r--r-- | lib/httpserver/HTTPServer.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/httpserver/HTTPServer.cpp b/lib/httpserver/HTTPServer.cpp index be1db687..a2daed99 100644 --- a/lib/httpserver/HTTPServer.cpp +++ b/lib/httpserver/HTTPServer.cpp @@ -27,8 +27,8 @@ // Created: 26/3/04 // // -------------------------------------------------------------------------- -HTTPServer::HTTPServer() - : mTimeout(20000) // default timeout leaves a little while for clients to get the second request in. +HTTPServer::HTTPServer(int Timeout) +: mTimeout(Timeout) { } @@ -86,7 +86,7 @@ const ConfigurationVerify *HTTPServer::GetConfigVerify() const 0 } }; - + static ConfigurationVerifyKey verifyrootkeys[] = { HTTPSERVER_VERIFY_ROOT_KEYS @@ -132,10 +132,10 @@ void HTTPServer::Run() // Created: 26/3/04 // // -------------------------------------------------------------------------- -void HTTPServer::Connection(SocketStream &rStream) +void HTTPServer::Connection(std::auto_ptr<SocketStream> apConn) { // Create a get line object to use - IOStreamGetLine getLine(rStream); + IOStreamGetLine getLine(*apConn); // Notify dervived claases HTTPConnectionOpening(); @@ -150,10 +150,10 @@ void HTTPServer::Connection(SocketStream &rStream) // Didn't get request, connection probably closed. break; } - + // Generate a response - HTTPResponse response(&rStream); - + HTTPResponse response(apConn.get()); + try { Handle(request, response); @@ -169,9 +169,18 @@ void HTTPServer::Connection(SocketStream &rStream) { SendInternalErrorResponse("unknown", response); } - - // Keep alive? - if(request.GetClientKeepAliveRequested()) + + // Keep alive? response.GetSize() works for CollectInBufferStream, but + // when we make HTTPResponse stream the response instead, we'll need to + // figure out whether we can get the response length from the IOStream + // to be streamed, or not. Also, we don't currently support chunked + // encoding, and http://tools.ietf.org/html/rfc7230#section-3.3.1 says + // that "If any transfer coding other than chunked is applied to a + // response payload body, the sender MUST either apply chunked as the + // final transfer coding or terminate the message by closing the + // connection. So for now, keepalive stays off. + if(false && request.GetClientKeepAliveRequested() && + response.GetSize() >= 0) { // Mark the response to the client as supporting keepalive response.SetKeepAlive(true); |