mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-23 08:45:22 +03:00
WebServer: Allow client to send many requests on the same connection (#7414)
* WebServer: Allow client to send many requests on the same connection * WebServer: Keep the connection alive with a client by default * WebServer: Use the request's HTTP version and Connection header to set the default keep alive value * Fix a typo in a comment
This commit is contained in:
committed by
GitHub
parent
709ba7981e
commit
3c1bd65a76
@ -114,6 +114,9 @@ bool ESP8266WebServerTemplate<ServerType>::_parseRequest(ClientType& client) {
|
||||
}
|
||||
_currentMethod = method;
|
||||
|
||||
_keepAlive = _currentVersion > 0; // Keep the connection alive by default
|
||||
// if the protocol version is greater than HTTP 1.0
|
||||
|
||||
#ifdef DEBUG_ESP_HTTP_SERVER
|
||||
DEBUG_OUTPUT.print("method: ");
|
||||
DEBUG_OUTPUT.print(methodStr);
|
||||
@ -144,7 +147,7 @@ bool ESP8266WebServerTemplate<ServerType>::_parseRequest(ClientType& client) {
|
||||
while(1){
|
||||
req = client.readStringUntil('\r');
|
||||
client.readStringUntil('\n');
|
||||
if (req.isEmpty()) break;//no moar headers
|
||||
if (req.isEmpty()) break; //no more headers
|
||||
int headerDiv = req.indexOf(':');
|
||||
if (headerDiv == -1){
|
||||
break;
|
||||
@ -177,6 +180,8 @@ bool ESP8266WebServerTemplate<ServerType>::_parseRequest(ClientType& client) {
|
||||
contentLength = headerValue.toInt();
|
||||
} else if (headerName.equalsIgnoreCase(F("Host"))){
|
||||
_hostHeader = headerValue;
|
||||
} else if (headerName.equalsIgnoreCase(F("Connection"))){
|
||||
_keepAlive = headerValue.equalsIgnoreCase(F("keep-alive"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,6 +246,8 @@ bool ESP8266WebServerTemplate<ServerType>::_parseRequest(ClientType& client) {
|
||||
|
||||
if (headerName.equalsIgnoreCase(F("Host"))){
|
||||
_hostHeader = headerValue;
|
||||
} else if (headerName.equalsIgnoreCase(F("Connection"))){
|
||||
_keepAlive = headerValue.equalsIgnoreCase(F("keep-alive"));
|
||||
}
|
||||
}
|
||||
_parseArguments(searchStr);
|
||||
|
Reference in New Issue
Block a user