summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/io/http_client.cpp16
-rw-r--r--core/io/http_client.h2
-rw-r--r--core/project_settings.cpp2
3 files changed, 19 insertions, 1 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 9d541c4fa7..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;
@@ -715,11 +724,16 @@ void HTTPClient::set_read_chunk_size(int p_size) {
read_chunk_size = p_size;
}
+int HTTPClient::get_read_chunk_size() const {
+ return read_chunk_size;
+}
+
HTTPClient::HTTPClient() {
tcp_connection.instance();
resolving = IP::RESOLVER_INVALID_ID;
status = STATUS_DISCONNECTED;
+ head_request = false;
conn_port = -1;
body_size = -1;
chunked = false;
@@ -818,6 +832,7 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_response_body_length"), &HTTPClient::get_response_body_length);
ClassDB::bind_method(D_METHOD("read_response_body_chunk"), &HTTPClient::read_response_body_chunk);
ClassDB::bind_method(D_METHOD("set_read_chunk_size", "bytes"), &HTTPClient::set_read_chunk_size);
+ ClassDB::bind_method(D_METHOD("get_read_chunk_size"), &HTTPClient::get_read_chunk_size);
ClassDB::bind_method(D_METHOD("set_blocking_mode", "enabled"), &HTTPClient::set_blocking_mode);
ClassDB::bind_method(D_METHOD("is_blocking_mode_enabled"), &HTTPClient::is_blocking_mode_enabled);
@@ -829,6 +844,7 @@ void HTTPClient::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_mode_enabled"), "set_blocking_mode", "is_blocking_mode_enabled");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "connection", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", 0), "set_connection", "get_connection");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "read_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_read_chunk_size", "get_read_chunk_size");
BIND_ENUM_CONSTANT(METHOD_GET);
BIND_ENUM_CONSTANT(METHOD_HEAD);
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 85ee1959a2..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;
@@ -220,6 +221,7 @@ public:
bool is_blocking_mode_enabled() const;
void set_read_chunk_size(int p_size);
+ int get_read_chunk_size() const;
Error poll();
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index ba5cdd782f..067578e354 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -107,7 +107,7 @@ String ProjectSettings::localize_path(const String &p_path) const {
if (plocal == "") {
return "";
};
- return plocal + path.substr((sep + 1), path.size() - (sep + 1));
+ return plocal + path.substr(sep, path.size() - sep);
};
}