summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wuttke <mewin@mewin.de>2019-11-15 14:59:49 +0100
committerPatrick Wuttke <mewin@mewin.de>2019-11-26 14:17:34 +0100
commit2cd68a25660ddfd9c0ce376ab95d534ad7009a74 (patch)
tree5b511eec3ad81ab00ab4dcf81e97d6f2628ce74d
parent98caeb635c2e4d48e0d6d6dbd82af183ab83f894 (diff)
do not wait for response body when making a HEAD request
-rw-r--r--core/io/http_client.cpp10
-rw-r--r--core/io/http_client.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 170bef4430..bb1befb297 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -171,6 +171,7 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector
}
status = STATUS_REQUESTING;
+ head_request = p_method == METHOD_HEAD;
return OK;
}
@@ -226,6 +227,7 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str
}
status = STATUS_REQUESTING;
+ head_request = p_method == METHOD_HEAD;
return OK;
}
@@ -267,6 +269,7 @@ void HTTPClient::close() {
connection.unref();
status = STATUS_DISCONNECTED;
+ head_request = false;
if (resolving != IP::RESOLVER_INVALID_ID) {
IP::get_singleton()->erase_resolve_item(resolving);
@@ -468,6 +471,12 @@ Error HTTPClient::poll() {
}
}
+ // This is a HEAD request, we wont receive anything.
+ if (head_request) {
+ body_size = 0;
+ body_left = 0;
+ }
+
if (body_size != -1 || chunked) {
status = STATUS_BODY;
@@ -718,6 +727,7 @@ HTTPClient::HTTPClient() {
tcp_connection.instance();
resolving = IP::RESOLVER_INVALID_ID;
status = STATUS_DISCONNECTED;
+ head_request = false;
conn_port = -1;
body_size = -1;
chunked = false;
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 85ee1959a2..33e4d15106 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -166,6 +166,7 @@ private:
bool ssl_verify_host;
bool blocking;
bool handshaking;
+ bool head_request;
Vector<uint8_t> response_str;