Mercurial > hg > orthanc
diff OrthancFramework/Sources/HttpServer/HttpOutput.cpp @ 4301:6919242d2265
Fix keep-alive in the embedded HTTP server by setting the "Keep-Alive" HTTP header
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 06 Nov 2020 09:58:48 +0100 |
parents | db3932f9660d |
children | d9473bd5ed43 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/HttpServer/HttpOutput.cpp Thu Nov 05 19:33:18 2020 +0100 +++ b/OrthancFramework/Sources/HttpServer/HttpOutput.cpp Fri Nov 06 09:58:48 2020 +0100 @@ -174,6 +174,21 @@ if (keepAlive_) { s += "Connection: keep-alive\r\n"; + + /** + * [LIFY-2311] The "Keep-Alive" HTTP header was missing in + * Orthanc <= 1.8.0, which notably caused failures if + * uploading DICOM instances by applying Java's + * "org.apache.http.client.methods.HttpPost()" on "/instances" + * URI, if "PoolingHttpClientConnectionManager" was in used. A + * workaround was to manually set a timeout for the keep-alive + * client to, say, 200 milliseconds, by using + * "HttpClients.custom().setKeepAliveStrategy((httpResponse,httpContext)->200)". + * Note that the "timeout" value can only be integer in the + * HTTP header, so we can't use the milliseconds granularity. + **/ + s += ("Keep-Alive: timeout=" + + boost::lexical_cast<std::string>(CIVETWEB_KEEP_ALIVE_TIMEOUT_SECONDS) + "\r\n"); } else {