Verify custom HTTP headers, fix off by one error
This commit is contained in:
parent
3a83872d26
commit
3ef5a97505
5 changed files with 25 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue