comparison OrthancFramework/Sources/HttpServer/HttpOutput.cpp @ 5119:bdec57f3cbf2

New configuration KeepAliveTimeout with a default value of 1 second
author Alain Mazy <am@osimis.io>
date Wed, 14 Dec 2022 11:50:43 +0100
parents 43e613a7756b
children 0ea402b4d901
comparison
equal deleted inserted replaced
5118:030cd210845e 5119:bdec57f3cbf2
45 45
46 46
47 namespace Orthanc 47 namespace Orthanc
48 { 48 {
49 HttpOutput::StateMachine::StateMachine(IHttpOutputStream& stream, 49 HttpOutput::StateMachine::StateMachine(IHttpOutputStream& stream,
50 bool isKeepAlive) : 50 bool isKeepAlive,
51 unsigned int keepAliveTimeout) :
51 stream_(stream), 52 stream_(stream),
52 state_(State_WritingHeader), 53 state_(State_WritingHeader),
53 status_(HttpStatus_200_Ok), 54 status_(HttpStatus_200_Ok),
54 hasContentLength_(false), 55 hasContentLength_(false),
55 contentLength_(0), 56 contentLength_(0),
56 contentPosition_(0), 57 contentPosition_(0),
57 keepAlive_(isKeepAlive) 58 keepAlive_(isKeepAlive),
59 keepAliveTimeout_(keepAliveTimeout)
58 { 60 {
59 } 61 }
60 62
61 HttpOutput::StateMachine::~StateMachine() 63 HttpOutput::StateMachine::~StateMachine()
62 { 64 {
187 * "HttpClients.custom().setKeepAliveStrategy((httpResponse,httpContext)->200)". 189 * "HttpClients.custom().setKeepAliveStrategy((httpResponse,httpContext)->200)".
188 * Note that the "timeout" value can only be integer in the 190 * Note that the "timeout" value can only be integer in the
189 * HTTP header, so we can't use the milliseconds granularity. 191 * HTTP header, so we can't use the milliseconds granularity.
190 **/ 192 **/
191 s += ("Keep-Alive: timeout=" + 193 s += ("Keep-Alive: timeout=" +
192 boost::lexical_cast<std::string>(CIVETWEB_KEEP_ALIVE_TIMEOUT_SECONDS) + "\r\n"); 194 boost::lexical_cast<std::string>(keepAliveTimeout_) + "\r\n");
193 } 195 }
194 else 196 else
195 { 197 {
196 s += "Connection: close\r\n"; 198 s += "Connection: close\r\n";
197 } 199 }
297 } 299 }
298 } 300 }
299 301
300 302
301 HttpOutput::HttpOutput(IHttpOutputStream &stream, 303 HttpOutput::HttpOutput(IHttpOutputStream &stream,
302 bool isKeepAlive) : 304 bool isKeepAlive,
303 stateMachine_(stream, isKeepAlive), 305 unsigned int keepAliveTimeout) :
306 stateMachine_(stream, isKeepAlive, keepAliveTimeout),
304 isDeflateAllowed_(false), 307 isDeflateAllowed_(false),
305 isGzipAllowed_(false) 308 isGzipAllowed_(false)
306 { 309 {
307 } 310 }
308 311