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 ea637f641e
commit e3292633be
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 3 additions and 3 deletions

View file

@ -555,7 +555,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

@ -180,8 +180,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;