Fix http limitation for large "content-length"

When a request was issued to a server that returned "content-length" header
whose value was greater than that of an "int" we ran into overflow
problems. The fix for this was rather simple by increasing the data
type to `int64_t`

(cherry picked from commit 69a532414c)
This commit is contained in:
Cnidarias 2021-12-30 01:16:19 +01:00 committed by Rémi Verschelde
parent 1908e3fe9e
commit 39cdd57114
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 3 additions and 3 deletions

View File

@ -491,7 +491,7 @@ Error HTTPClient::poll() {
continue;
}
if (s.begins_with("content-length:")) {
body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int();
body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int64();
body_left = body_size;
} else if (s.begins_with("transfer-encoding:")) {

View File

@ -174,8 +174,8 @@ private:
Vector<uint8_t> chunk;
int chunk_left;
bool chunk_trailer_part;
int body_size;
int body_left;
int64_t body_size;
int64_t body_left;
bool read_until_eof;
Ref<StreamPeerTCP> tcp_connection;