diff options
| author | Juan Linietsky <reduzio@gmail.com> | 2018-04-07 17:07:29 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-07 17:07:29 -0300 |
| commit | cd7e9d964281d700de691eb48eb4b597c8fd947a (patch) | |
| tree | a21f197b45c6cc3cf222db16bb74e8535a750593 /core/io/http_client.cpp | |
| parent | 61d70fe47cfaa4efee505c7073aacfe34b66c217 (diff) | |
| parent | 1fc85b87bd0542b82b1a8d51afdb3801d03d872b (diff) | |
Merge pull request #17583 from RandomShaper/enhance-uri-utils
Enhance uri utils
Diffstat (limited to 'core/io/http_client.cpp')
| -rw-r--r-- | core/io/http_client.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 4d72f744e1..c787b7ec4c 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -618,7 +618,27 @@ String HTTPClient::query_string_from_dict(const Dictionary &p_dict) { String query = ""; Array keys = p_dict.keys(); for (int i = 0; i < keys.size(); ++i) { - query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape(); + String encoded_key = String(keys[i]).percent_encode(); + Variant value = p_dict[keys[i]]; + switch (value.get_type()) { + case Variant::ARRAY: { + // Repeat the key with every values + Array values = value; + for (int j = 0; j < values.size(); ++j) { + query += "&" + encoded_key + "=" + String(values[j]).percent_encode(); + } + break; + } + case Variant::NIL: { + // Add the key with no value + query += "&" + encoded_key; + break; + } + default: { + // Add the key-value pair + query += "&" + encoded_key + "=" + String(value).percent_encode(); + } + } } query.erase(0, 1); return query; |