mirror of
https://github.com/godotengine/godot.git
synced 2025-10-24 10:23:28 +00:00
[HTML5] Fix HTTPClient request_raw.
Now send data according to the spec, properly handle null data. Simplify JS code since we are at it.
This commit is contained in:
parent
ad293a82f1
commit
75c4e2c5fa
3 changed files with 18 additions and 29 deletions
|
|
@ -104,7 +104,11 @@ 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;
|
||||
godot_xhr_send_data(xhr_id, p_body.ptr(), p_body.size());
|
||||
if (p_body.is_empty()) {
|
||||
godot_xhr_send(xhr_id, nullptr, 0);
|
||||
} else {
|
||||
godot_xhr_send(xhr_id, p_body.ptr(), p_body.size());
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +116,12 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str
|
|||
Error err = prepare_request(p_method, p_url, p_headers);
|
||||
if (err != OK)
|
||||
return err;
|
||||
godot_xhr_send_string(xhr_id, p_body.utf8().get_data());
|
||||
if (p_body.is_empty()) {
|
||||
godot_xhr_send(xhr_id, nullptr, 0);
|
||||
} else {
|
||||
const CharString cs = p_body.utf8();
|
||||
godot_xhr_send(xhr_id, cs.get_data(), cs.length());
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue