1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

add CHUNKED encoding support too http client (#1324)

HTTP Client - fix examples
increase default timeout to 5000ms
This commit is contained in:
Markus Sattler
2015-12-30 19:38:06 +01:00
parent bbaed29b7e
commit cc0037682b
6 changed files with 146 additions and 55 deletions

View File

@ -25,13 +25,13 @@
#ifndef ESP8266HTTPClient_H_
#define ESP8266HTTPClient_H_
//#define DEBUG_HTTPCLIENT(...) Serial1.printf( __VA_ARGS__ )
#define DEBUG_HTTPCLIENT(...) Serial1.printf( __VA_ARGS__ )
#ifndef DEBUG_HTTPCLIENT
#define DEBUG_HTTPCLIENT(...)
#endif
#define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (1000)
#define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (5000)
/// HTTP client errors
#define HTTPC_ERROR_CONNECTION_REFUSED (-1)
@ -42,6 +42,8 @@
#define HTTPC_ERROR_NO_STREAM (-6)
#define HTTPC_ERROR_NO_HTTP_SERVER (-7)
#define HTTPC_ERROR_TOO_LESS_RAM (-8)
#define HTTPC_ERROR_ENCODING (-9)
/// size for the stream handling
#define HTTP_TCP_BUFFER_SIZE (1460)
@ -108,6 +110,11 @@ typedef enum {
HTTP_CODE_NETWORK_AUTHENTICATION_REQUIRED = 511
} t_http_codes;
typedef enum {
HTTPC_TE_IDENTITY,
HTTPC_TE_CHUNKED
} transferEncoding_t;
class HTTPClient {
public:
HTTPClient();
@ -188,11 +195,13 @@ class HTTPClient {
int _returnCode;
int _size;
bool _canReuse;
transferEncoding_t _transferEncoding;
bool connect(void);
bool sendHeader(const char * type);
int handleHeaderResponse();
int writeToStreamDataBlock(Stream * stream, int len);
};