Implement HTTPClient in HTML5 platform

Limitations:

 - Subject to same-origin policy
 - No persistent connection (but simulated for compatibility)
 - No blocking mode
 - No StreamPeer access
 - No chunked responses
 - Cannot disable host verification
This commit is contained in:
Leon Krause 2017-10-26 03:39:41 +02:00
parent faf21d895e
commit 2970061a73
7 changed files with 633 additions and 70 deletions

View file

@ -131,6 +131,7 @@ public:
};
private:
#ifndef JAVASCRIPT_ENABLED
Status status;
IP::ResolverID resolving;
int conn_port;
@ -152,14 +153,19 @@ private:
int response_num;
Vector<String> response_headers;
static void _bind_methods();
PoolStringArray _get_response_headers();
Dictionary _get_response_headers_as_dictionary();
int read_chunk_size;
Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received);
#else
#include "platform/javascript/http_client.h.inc"
#endif
PoolStringArray _get_response_headers();
Dictionary _get_response_headers_as_dictionary();
static void _bind_methods();
public:
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
Error connect_to_host(const String &p_host, int p_port, bool p_ssl = false, bool p_verify_host = true);