summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-12-01 05:50:33 +0100
committerGitHub <noreply@github.com>2019-12-01 05:50:33 +0100
commit6f38aeef5255d1fdeb99d727a0f67b9be6ccdf36 (patch)
treea0fd7ac0cdff3fad963a01f2c02cbeea8840c018 /core/io
parentdac2a7b2378973177a166f1f4c0f6ac3c7b3e529 (diff)
parent2cd68a25660ddfd9c0ce376ab95d534ad7009a74 (diff)
Merge pull request #33640 from mewin/http_head_request
Fix HTTP HEAD requests
Diffstat (limited to 'core/io')
-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 1904c70f42..bfa272e859 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -173,6 +173,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;
}
@@ -228,6 +229,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;
}
@@ -269,6 +271,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);
@@ -470,6 +473,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;
@@ -724,6 +733,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 ce7fe0491b..27c6711bcf 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;