Use new way to detect eof

This commit is contained in:
2024-01-10 21:45:37 +08:00
parent c43edb26eb
commit c753f200cd
2 changed files with 99 additions and 22 deletions

View File

@@ -137,10 +137,12 @@ typedef struct Response Response;
class Request {
public:
Request(std::string host, std::string port, bool https, std::string path, std::string method, HeaderMap headers, HttpClientOptions options);
Request(std::string url, std::string method, HttpClientOptions options = {}, HeaderMap headers = {});
~Request();
Response send();
HeaderMap headers;
HttpClientOptions options;
HttpBody* getBody();
void setBody(HttpBody* body);
std::string host;
std::string port;
@@ -161,6 +163,7 @@ public:
std::string reason;
std::string read();
std::string readAll();
bool isEof();
private:
std::string readLine();
void parseHeader();
@@ -168,6 +171,7 @@ private:
bool pullData();
bool headerParsed = false;
bool chunked = false;
bool eof = false;
#if HAVE_ZLIB
bool gzip = false;
bool deflate = false;