diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-02-02 18:28:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-02 18:28:30 +0100 |
commit | 6ff753675a1c6f86ece68905bdedbf5e81712800 (patch) | |
tree | 1313c15c5c7150d38975183c052e22fcd16b7a4f /core/io/http_client.cpp | |
parent | 68e62fb5cde0891416e0eed5f4e3f9e9d5f63d82 (diff) | |
parent | 3ef5a975054834466107ed8598352e5315a3a191 (diff) |
Merge pull request #56771 from mhilbrunner/unacceptable
Verify custom HTTP headers, fix off by one error
Diffstat (limited to 'core/io/http_client.cpp')
-rw-r--r-- | core/io/http_client.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 4d0747c591..52b1120b2a 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -96,6 +96,17 @@ String HTTPClient::query_string_from_dict(const Dictionary &p_dict) { return query.substr(1); } +Error HTTPClient::verify_headers(const Vector<String> &p_headers) { + for (int i = 0; i < p_headers.size(); i++) { + String sanitized = p_headers[i].strip_edges(); + ERR_FAIL_COND_V_MSG(sanitized.is_empty(), ERR_INVALID_PARAMETER, "Invalid HTTP header at index " + itos(i) + ": empty."); + ERR_FAIL_COND_V_MSG(sanitized.find(":") < 1, ERR_INVALID_PARAMETER, + "Invalid HTTP header at index " + itos(i) + ": String must contain header-value pair, delimited by ':', but was: " + p_headers[i]); + } + + return OK; +} + Dictionary HTTPClient::_get_response_headers_as_dictionary() { List<String> rh; get_response_headers(&rh); |