mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
handle empty uri
http.begin("http://www.google.com") yields an empty uri and makes a broken request "GET HTTPi/1.1"
This commit is contained in:
parent
4c08389961
commit
db1cfc7772
@ -44,6 +44,8 @@ public:
|
|||||||
|
|
||||||
virtual bool verify(WiFiClient& client, const char* host)
|
virtual bool verify(WiFiClient& client, const char* host)
|
||||||
{
|
{
|
||||||
|
(void)client;
|
||||||
|
(void)host;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -167,6 +169,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
|
|||||||
_host = host;
|
_host = host;
|
||||||
}
|
}
|
||||||
_uri = url;
|
_uri = url;
|
||||||
|
|
||||||
if (_protocol != expectedProtocol) {
|
if (_protocol != expectedProtocol) {
|
||||||
DEBUG_HTTPCLIENT("[HTTP-Client][begin] unexpected protocol: %s, expected %s\n", _protocol.c_str(), expectedProtocol);
|
DEBUG_HTTPCLIENT("[HTTP-Client][begin] unexpected protocol: %s, expected %s\n", _protocol.c_str(), expectedProtocol);
|
||||||
return false;
|
return false;
|
||||||
@ -871,7 +874,7 @@ bool HTTPClient::sendHeader(const char * type)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String header = String(type) + " " + _uri + F(" HTTP/1.");
|
String header = String(type) + " " + (_uri.length() ? _uri : F("/")) + F(" HTTP/1.");
|
||||||
|
|
||||||
if(_useHTTP10) {
|
if(_useHTTP10) {
|
||||||
header += "0";
|
header += "0";
|
||||||
@ -908,6 +911,8 @@ bool HTTPClient::sendHeader(const char * type)
|
|||||||
|
|
||||||
header += _headers + "\r\n";
|
header += _headers + "\r\n";
|
||||||
|
|
||||||
|
DEBUG_HTTPCLIENT("[HTTP-Client] sending request header\n-----\n%s-----\n", header.c_str());
|
||||||
|
|
||||||
return (_tcp->write((const uint8_t *) header.c_str(), header.length()) == header.length());
|
return (_tcp->write((const uint8_t *) header.c_str(), header.length()) == header.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user