From e3292633be14968c449b68159d866bd47a21d8d7 Mon Sep 17 00:00:00 2001 From: Cnidarias Date: Thu, 30 Dec 2021 01:16:19 +0100 Subject: [PATCH] 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 69a532414c87bfbc7465c45b92f7315d3edf206b) --- core/io/http_client.cpp | 2 +- core/io/http_client.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index cfeca83ec9d..3e466044a14 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -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:")) { diff --git a/core/io/http_client.h b/core/io/http_client.h index 972c652fd2f..d8fb98d6225 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -180,8 +180,8 @@ private: Vector 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 tcp_connection;