mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
allow downgrade to HTTP 1.0
use HTTP/1.0 for update since the update handler not support any transfer Encoding
This commit is contained in:
parent
b828f34348
commit
ef748e369a
@ -41,6 +41,7 @@ HTTPClient::HTTPClient() {
|
||||
|
||||
_reuse = false;
|
||||
_tcpTimeout = HTTPCLIENT_DEFAULT_TCP_TIMEOUT;
|
||||
_useHTTP10 = false;
|
||||
|
||||
_https = false;
|
||||
|
||||
@ -266,6 +267,16 @@ void HTTPClient::setTimeout(uint16_t timeout) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* use HTTP1.0
|
||||
* @param timeout
|
||||
*/
|
||||
void HTTPClient::useHTTP10(bool useHTTP10) {
|
||||
_useHTTP10 = useHTTP10;
|
||||
}
|
||||
|
||||
/**
|
||||
* send a GET request
|
||||
* @return http code
|
||||
@ -757,10 +768,17 @@ bool HTTPClient::sendHeader(const char * type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String header = String(type) + " " + _url + " HTTP/1.1\r\n"
|
||||
String header = String(type) + " " + _url + " HTTP/1.";
|
||||
|
||||
if(_useHTTP10) {
|
||||
header += "0";
|
||||
} else {
|
||||
header += "1";
|
||||
}
|
||||
|
||||
header += "\r\n"
|
||||
"Host: " + _host + "\r\n"
|
||||
"User-Agent: " + _userAgent + "\r\n"
|
||||
"Accept-Encoding: identity;q=1 chunked;q=0.1 *;q=0\r\n"
|
||||
"Connection: ";
|
||||
|
||||
if(_reuse) {
|
||||
@ -770,6 +788,10 @@ bool HTTPClient::sendHeader(const char * type) {
|
||||
}
|
||||
header += "\r\n";
|
||||
|
||||
if(!_useHTTP10) {
|
||||
header += "Accept-Encoding: identity;q=1 chunked;q=0.1 *;q=0\r\n";
|
||||
}
|
||||
|
||||
if(_base64Authorization.length()) {
|
||||
header += "Authorization: Basic " + _base64Authorization + "\r\n";
|
||||
}
|
||||
|
@ -137,6 +137,8 @@ class HTTPClient {
|
||||
void setAuthorization(const char * auth);
|
||||
void setTimeout(uint16_t timeout);
|
||||
|
||||
void useHTTP10(bool usehttp10 = true);
|
||||
|
||||
/// request handling
|
||||
int GET();
|
||||
int POST(uint8_t * payload, size_t size);
|
||||
@ -180,6 +182,7 @@ class HTTPClient {
|
||||
uint16_t _port;
|
||||
bool _reuse;
|
||||
uint16_t _tcpTimeout;
|
||||
bool _useHTTP10;
|
||||
|
||||
String _url;
|
||||
bool _https;
|
||||
|
@ -146,6 +146,9 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha
|
||||
|
||||
t_httpUpdate_return ret = HTTP_UPDATE_FAILED;
|
||||
|
||||
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
|
||||
http->useHTTP10(true);
|
||||
http->setTimeout(8000);
|
||||
http->setUserAgent("ESP8266-http-Update");
|
||||
http->addHeader("x-ESP8266-STA-MAC", WiFi.macAddress());
|
||||
http->addHeader("x-ESP8266-AP-MAC", WiFi.softAPmacAddress());
|
||||
|
Loading…
x
Reference in New Issue
Block a user