Skip to content

Commit b0f3960

Browse files
authored
Merge pull request meshtastic#7 from cpatulea/master
2 parents 3223704 + 4f5494b commit b0f3960

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/HTTPConnection.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ HTTPConnection::HTTPConnection(ResourceResolver * resResolver):
1212

1313
_connectionState = STATE_UNDEFINED;
1414
_clientState = CSTATE_UNDEFINED;
15+
_http1_1 = false;
1516
_defaultHeaders = NULL;
1617
_isKeepAlive = false;
1718
_lastTransmissionTS = millis();
@@ -380,6 +381,11 @@ void HTTPConnection::loop() {
380381
}
381382
_httpResource = _parserLine.text.substr(spaceAfterMethodIdx + 1, spaceAfterResourceIdx - _httpMethod.length() - 1);
382383

384+
// Check for HTTP/1.1
385+
if (spaceAfterResourceIdx + 1 < _parserLine.text.size()) {
386+
_http1_1 = _parserLine.text.substr(spaceAfterResourceIdx + 1).compare("HTTP/1.1") >= 0;
387+
}
388+
383389
_parserLine.parsingFinished = false;
384390
_parserLine.text = "";
385391
HTTPS_LOGI("Request: %s %s (FID=%d)", _httpMethod.c_str(), _httpResource.c_str(), _socket);
@@ -448,7 +454,7 @@ void HTTPConnection::loop() {
448454
[](unsigned char c){ return ::tolower(c); }
449455
);
450456
}
451-
if (std::string("keep-alive").compare(connectionHeaderValue)==0) {
457+
if (_http1_1 || std::string("keep-alive").compare(connectionHeaderValue)==0) {
452458
HTTPS_LOGD("Keep-Alive activated. FID=%d", _socket);
453459
_isKeepAlive = true;
454460
} else {

src/HTTPConnection.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class HTTPConnection : private ConnectionContext {
149149
// HTTP properties: Method, Request, Headers
150150
std::string _httpMethod;
151151
std::string _httpResource;
152+
bool _http1_1;
152153
HTTPHeaders _httpHeaders;
153154

154155
// Default headers that are applied to every response

0 commit comments

Comments
 (0)