diff options
author | Leon Krause <lk@leonkrause.com> | 2018-02-16 05:38:36 +0100 |
---|---|---|
committer | Leon Krause <lk@leonkrause.com> | 2018-02-16 05:38:36 +0100 |
commit | 8a21f27f540750a76f19fcfb7d7a9d5e7f03f771 (patch) | |
tree | ba5d554215d6d1466ddd44cd11fa047101e95131 /platform | |
parent | 9ea4452d2118fb071066cce1e2e2525bc4e29841 (diff) |
Fix HTML5 HTTPClient response header retrieval
Diffstat (limited to 'platform')
-rw-r--r-- | platform/javascript/http_client_javascript.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp index badfe40e66..5e6b01f772 100644 --- a/platform/javascript/http_client_javascript.cpp +++ b/platform/javascript/http_client_javascript.cpp @@ -158,7 +158,7 @@ int HTTPClient::get_response_code() const { Error HTTPClient::get_response_headers(List<String> *r_response) { - if (!polled_response_header.size()) + if (polled_response_header.empty()) return ERR_INVALID_PARAMETER; Vector<String> header_lines = polled_response_header.split("\r\n", false); @@ -250,9 +250,11 @@ Error HTTPClient::poll() { PoolByteArray bytes; int len = godot_xhr_get_response_headers_length(xhr_id); - bytes.resize(len); + bytes.resize(len + 1); + PoolByteArray::Write write = bytes.write(); godot_xhr_get_response_headers(xhr_id, reinterpret_cast<char *>(write.ptr()), len); + write[len] = 0; write = PoolByteArray::Write(); PoolByteArray::Read read = bytes.read(); |