From 4086a123b9873543b05ecbfc0f7db4d95748c040 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 11 Feb 2021 09:32:17 +0100 Subject: [PATCH] [HTML5] Fix HTTPClient request_raw. Now send data according to the spec, properly handle null data. Simplify JS code since we are at it. --- .../javascript/http_client_javascript.cpp | 15 ++++++++-- platform/javascript/http_request.h | 4 +-- .../js/libs/library_godot_http_request.js | 30 ++++--------------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp index 10ed1210650..8eec5106529 100644 --- a/platform/javascript/http_client_javascript.cpp +++ b/platform/javascript/http_client_javascript.cpp @@ -108,8 +108,12 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector Error err = prepare_request(p_method, p_url, p_headers); if (err != OK) return err; - PoolByteArray::Read read = p_body.read(); - godot_xhr_send_data(xhr_id, read.ptr(), p_body.size()); + if (p_body.empty()) { + godot_xhr_send(xhr_id, nullptr, 0); + } else { + PoolByteArray::Read read = p_body.read(); + godot_xhr_send(xhr_id, read.ptr(), p_body.size()); + } return OK; } @@ -118,7 +122,12 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector