Mercurial > hg > orthanc
comparison OrthancFramework/Sources/HttpServer/HttpServer.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 | a01b1c9cbef4 |
comparison
equal
deleted
inserted
replaced
4300:b30a8de92ad9 | 4301:6919242d2265 |
---|---|
1541 if (!IsRunning()) | 1541 if (!IsRunning()) |
1542 { | 1542 { |
1543 std::string port = boost::lexical_cast<std::string>(port_); | 1543 std::string port = boost::lexical_cast<std::string>(port_); |
1544 std::string numThreads = boost::lexical_cast<std::string>(threadsCount_); | 1544 std::string numThreads = boost::lexical_cast<std::string>(threadsCount_); |
1545 std::string requestTimeoutMilliseconds = boost::lexical_cast<std::string>(requestTimeout_ * 1000); | 1545 std::string requestTimeoutMilliseconds = boost::lexical_cast<std::string>(requestTimeout_ * 1000); |
1546 std::string keepAliveTimeoutMilliseconds = boost::lexical_cast<std::string>(CIVETWEB_KEEP_ALIVE_TIMEOUT_SECONDS * 1000); | |
1546 | 1547 |
1547 if (ssl_) | 1548 if (ssl_) |
1548 { | 1549 { |
1549 port += "s"; | 1550 port += "s"; |
1550 } | 1551 } |
1559 // https://groups.google.com/d/msg/orthanc-users/CKueKX0pJ9E/_UCbl8T-VjIJ | 1560 // https://groups.google.com/d/msg/orthanc-users/CKueKX0pJ9E/_UCbl8T-VjIJ |
1560 options.push_back("enable_keep_alive"); | 1561 options.push_back("enable_keep_alive"); |
1561 options.push_back(keepAlive_ ? "yes" : "no"); | 1562 options.push_back(keepAlive_ ? "yes" : "no"); |
1562 | 1563 |
1563 #if ORTHANC_ENABLE_CIVETWEB == 1 | 1564 #if ORTHANC_ENABLE_CIVETWEB == 1 |
1564 // https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#enable_keep_alive-no | 1565 /** |
1566 * The "keep_alive_timeout_ms" cannot use milliseconds, as the | |
1567 * value of "timeout" in the HTTP header "Keep-Alive" must be | |
1568 * expressed in seconds (at least for the Java client). | |
1569 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive | |
1570 * https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#enable_keep_alive-no | |
1571 * https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#keep_alive_timeout_ms-500-or-0 | |
1572 **/ | |
1565 options.push_back("keep_alive_timeout_ms"); | 1573 options.push_back("keep_alive_timeout_ms"); |
1566 options.push_back(keepAlive_ ? "500" : "0"); | 1574 options.push_back(keepAlive_ ? keepAliveTimeoutMilliseconds.c_str() : "0"); |
1567 #endif | 1575 #endif |
1568 | 1576 |
1569 #if ORTHANC_ENABLE_CIVETWEB == 1 | 1577 #if ORTHANC_ENABLE_CIVETWEB == 1 |
1570 // Disable TCP Nagle's algorithm to maximize speed (this | 1578 // Disable TCP Nagle's algorithm to maximize speed (this |
1571 // option is not available in Mongoose). | 1579 // option is not available in Mongoose). |