Adds proxy support for HTTPClient

Also fixed a potential infinite loop when connecting to server.
This commit is contained in:
Haoyu Qiu
2021-07-03 13:11:59 +08:00
parent c5ab537617
commit c09ea8d45a
5 changed files with 129 additions and 8 deletions

View File

@ -38,8 +38,14 @@ private:
Status status = STATUS_DISCONNECTED;
IP::ResolverID resolving = IP::RESOLVER_INVALID_ID;
Array ip_candidates;
int conn_port = -1;
int conn_port = -1; // Server to make requests to
String conn_host;
int server_port = -1; // Server to connect to (might be a proxy server)
String server_host;
int http_proxy_port = -1; // Proxy server for http requests
String http_proxy_host;
int https_proxy_port = -1; // Proxy server for https requests
String https_proxy_host;
bool ssl = false;
bool ssl_verify_host = false;
bool blocking = false;
@ -58,6 +64,7 @@ private:
Ref<StreamPeerTCP> tcp_connection;
Ref<StreamPeer> connection;
Ref<HTTPClientTCP> proxy_client; // Negotiate with proxy server
int response_num = 0;
Vector<String> response_headers;
@ -87,6 +94,8 @@ public:
void set_read_chunk_size(int p_size) override;
int get_read_chunk_size() const override;
Error poll() override;
void set_http_proxy(const String &p_host, int p_port) override;
void set_https_proxy(const String &p_host, int p_port) override;
HTTPClientTCP();
};