summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorGagaPete <gagapeterbs@gmail.com>2018-07-04 01:18:26 +0200
committerGagaPete <gagapeterbs@gmail.com>2018-07-04 01:56:44 +0200
commit8a4dccc4ce91e26ddeda7fcb1409cdd251b17779 (patch)
tree76281b7875f3917c0ba15796bae753d6f17e3d3d /scene
parent085483e88577ea91400a1ee46bc4321340824c51 (diff)
Fix CORS problems due to added headers on JS target
Before this change, missing User-Agent and Accept headers were automatically added on all platforms. Setting the User-Agent header forces the browser to do a CORS preflight (see 1) which fails if the HTTP endpoint is not configured appropriate. It's not neccesary to set either header as the browser sets them and so this commit disables that functionality on the JS target. 1: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests
Diffstat (limited to 'scene')
-rw-r--r--scene/main/http_request.cpp20
1 files changed, 0 insertions, 20 deletions
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index ae21775c55..4750e05633 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -30,8 +30,6 @@
#include "http_request.h"
-#include "version.h"
-
void HTTPRequest::_redirect_request(const String &p_new_url) {
}
@@ -106,28 +104,10 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h
validate_ssl = p_ssl_validate_domain;
- bool has_user_agent = false;
- bool has_accept = false;
headers = p_custom_headers;
request_data = p_request_data;
- for (int i = 0; i < headers.size(); i++) {
-
- if (headers[i].findn("user-agent:") == 0)
- has_user_agent = true;
- if (headers[i].findn("Accept:") == 0)
- has_accept = true;
- }
-
- if (!has_user_agent) {
- headers.push_back("User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")");
- }
-
- if (!has_accept) {
- headers.push_back("Accept: */*");
- }
-
requesting = true;
if (use_threads) {