ESP8266
|
Classes | |
struct | RequestArgument |
Public Member Functions | |
HTTPClient () | |
~HTTPClient () | |
void | begin (const char *url, const char *httpsFingerprint="") |
void | begin (String url, String httpsFingerprint="") |
void | begin (const char *host, uint16_t port, const char *url="/", bool https=false, const char *httpsFingerprint="") |
void | begin (String host, uint16_t port, String url="/", bool https=false, String httpsFingerprint="") |
void | end (void) |
bool | connected (void) |
void | setReuse (bool reuse) |
void | setUserAgent (const char *userAgent) |
keep-alive More... | |
void | setAuthorization (const char *user, const char *password) |
void | setAuthorization (const char *auth) |
void | setTimeout (uint16_t timeout) |
int | GET () |
request handling More... | |
int | POST (uint8_t *payload, size_t size) |
int | POST (String payload) |
int | sendRequest (const char *type, uint8_t *payload=NULL, size_t size=0) |
int | sendRequest (const char *type, Stream *stream, size_t size=0) |
void | addHeader (const String &name, const String &value, bool first=false) |
void | collectHeaders (const char *headerKeys[], const size_t headerKeysCount) |
Response handling. More... | |
String | header (const char *name) |
String | header (size_t i) |
String | headerName (size_t i) |
int | headers () |
bool | hasHeader (const char *name) |
int | getSize (void) |
WiFiClient & | getStream (void) __attribute__((deprecated)) |
WiFiClient * | getStreamPtr (void) |
int | writeToStream (Stream *stream) |
String | getString (void) |
Static Public Member Functions | |
static String | errorToString (int error) |
Protected Member Functions | |
bool | connect (void) |
bool | sendHeader (const char *type) |
int | handleHeaderResponse () |
Protected Attributes | |
WiFiClient * | _tcp |
WiFiClientSecure * | _tcps |
String | _host |
request handling More... | |
uint16_t | _port |
bool | _reuse |
uint16_t | _tcpTimeout |
String | _url |
bool | _https |
String | _httpsFingerprint |
String | _Headers |
String | _userAgent |
String | _base64Authorization |
RequestArgument * | _currentHeaders |
Response handling. More... | |
size_t | _headerKeysCount |
int | _returnCode |
int | _size |
bool | _canReuse |
HTTPClient::HTTPClient | ( | ) |
ESP8266HTTPClient.cpp
Created on: 02.11.2015
Copyright (c) 2015 Markus Sattler. All rights reserved. This file is part of the ESP8266HTTPClient for Arduino.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA constractor
HTTPClient::~HTTPClient | ( | ) |
deconstractor
void HTTPClient::addHeader | ( | const String & | name, |
const String & | value, | ||
bool | first = false |
||
) |
adds Header to the request
name | |
value | |
first |
void HTTPClient::begin | ( | const char * | url, |
const char * | httpsFingerprint = "" |
||
) |
phasing the url for all needed informations
url | const char * |
httpsFingerprint | const char * |
void HTTPClient::begin | ( | String | url, |
String | httpsFingerprint = "" |
||
) |
phasing the url for all needed informations
url | String |
httpsFingerprint | String |
void HTTPClient::begin | ( | const char * | host, |
uint16_t | port, | ||
const char * | url = "/" , |
||
bool | https = false , |
||
const char * | httpsFingerprint = "" |
||
) |
begin
host | const char * |
port | uint16_t |
url | const char * |
https | bool |
httpsFingerprint | const char * |
void HTTPClient::begin | ( | String | host, |
uint16_t | port, | ||
String | url = "/" , |
||
bool | https = false , |
||
String | httpsFingerprint = "" |
||
) |
void HTTPClient::collectHeaders | ( | const char * | headerKeys[], |
const size_t | headerKeysCount | ||
) |
Response handling.
|
protected |
init TCP connection and handle ssl verify if needed
bool HTTPClient::connected | ( | void | ) |
connected
void HTTPClient::end | ( | void | ) |
end called after the payload is handled
|
static |
converts error code to String
error | int |
int HTTPClient::GET | ( | ) |
request handling
send a GET request
int HTTPClient::getSize | ( | void | ) |
size of message body / payload
WiFiClient & HTTPClient::getStream | ( | void | ) |
deprecated Note: this is not working with https! returns the stream of the tcp connection
WiFiClient * HTTPClient::getStreamPtr | ( | void | ) |
returns the stream of the tcp connection
String HTTPClient::getString | ( | void | ) |
return all payload as String (may need lot of ram or trigger out of memory!)
|
protected |
reads the response from the server
bool HTTPClient::hasHeader | ( | const char * | name | ) |
String HTTPClient::header | ( | const char * | name | ) |
String HTTPClient::header | ( | size_t | i | ) |
String HTTPClient::headerName | ( | size_t | i | ) |
int HTTPClient::headers | ( | ) |
int HTTPClient::POST | ( | uint8_t * | payload, |
size_t | size | ||
) |
sends a post request to the server
payload | uint8_t * |
size | size_t |
int HTTPClient::POST | ( | String | payload | ) |
|
protected |
sends HTTP request header
type | (GET, POST, ...) |
int HTTPClient::sendRequest | ( | const char * | type, |
uint8_t * | payload = NULL , |
||
size_t | size = 0 |
||
) |
sendRequest
type | const char * "GET", "POST", .... |
payload | uint8_t * data for the message body if null not send |
size | size_t size for the message body if 0 not send |
int HTTPClient::sendRequest | ( | const char * | type, |
Stream * | stream, | ||
size_t | size = 0 |
||
) |
sendRequest
type | const char * "GET", "POST", .... |
stream | Stream * data stream for the message body |
size | size_t size for the message body if 0 not Content-Length is send |
void HTTPClient::setAuthorization | ( | const char * | user, |
const char * | password | ||
) |
set the Authorizatio for the http request
user | const char * |
password | const char * |
void HTTPClient::setAuthorization | ( | const char * | auth | ) |
set the Authorizatio for the http request
auth | const char * base64 |
void HTTPClient::setReuse | ( | bool | reuse | ) |
try to reuse the connection to the server keep-alive
reuse | bool |
void HTTPClient::setTimeout | ( | uint16_t | timeout | ) |
set the timeout for the TCP connection
timeout | unsigned int |
void HTTPClient::setUserAgent | ( | const char * | userAgent | ) |
keep-alive
set User Agent
userAgent | const char * |
int HTTPClient::writeToStream | ( | Stream * | stream | ) |
|
protected |
|
protected |
|
protected |
Response handling.
|
protected |
|
protected |
|
protected |
request handling
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |