A simple http client.
More...
#include <SimpleHTTPSocket.h>
|
| | SimpleHTTPSocket (const Module *module, HTTPCallback *callback=NULL) |
| |
| | SimpleHTTPSocket (const Module *module, const HTTPLamdbaCallback &callback, const HTTPLamdbaErrorCallback &errorcallback=nullptr) |
| |
| virtual | ~SimpleHTTPSocket () |
| |
| bool | Get (const String &url) |
| |
| bool | Post (const String &url, const String &postData, const String &type="") |
| |
| bool | Patch (const String &url, const String &patchData, const String &type="") |
| |
| bool | Put (const String &url, const String &putData, const String &type="") |
| |
| bool | Delete (const String &url, const String &deleteData, const String &type="") |
| |
| void | setExtraHeader (const String &key, const String &value) |
| |
| String | getURL () const |
| |
| | Socket (const Module *module) |
| |
| | Socket (struct bufferevent *event) |
| |
| virtual | ~Socket () |
| |
| void | Close () override |
| |
| bool | Connect (const String &hostname, uint16_t port, bool ssl=false, double timeout=60.0) |
| |
| bool | Connect (const IPAddress *ip, uint16_t port, bool ssl=false, double timeout=60.0) |
| |
| int | Write (const char *data, size_t len) override |
| |
| void | SetReadLine (bool b) |
| |
| bool | IsConnected () const |
| |
| void | SetTimeout (double timeout) |
| |
| void | DisableTimeout () |
| |
| const IPAddress * | GetIP () const |
| |
| | Event (const Module *module) |
| |
| virtual | ~Event () |
| |
| const Module * | GetModule () const |
| |
| int | WriteString (const String &data) |
| |
| virtual bool | shouldDelete () const override |
| |
| trippingcyril::net::http::SimpleHTTPSocket::SimpleHTTPSocket |
( |
const Module * |
module, |
|
|
HTTPCallback * |
callback = NULL |
|
) |
| |
General constructor and the place to register your callback
General constructor that uses lamdba functions instead of a general callback
- Note
- Requires C++11
| virtual trippingcyril::net::http::SimpleHTTPSocket::~SimpleHTTPSocket |
( |
| ) |
|
|
virtual |
| void trippingcyril::net::http::SimpleHTTPSocket::Connected |
( |
| ) |
|
|
overrideprotectedvirtual |
Connected event from the Socket class, make sure to call this implemention in case of overriding this class as it sends of the actual request etc.
Reimplemented from trippingcyril::net::Socket.
| bool trippingcyril::net::http::SimpleHTTPSocket::Delete |
( |
const String & |
url, |
|
|
const String & |
deleteData, |
|
|
const String & |
type = "" |
|
) |
| |
Do a simple HTTP DELETE request
- Parameters
-
| url | The url to request |
| deleteData | the raw put data to send |
| type | The Content-Type header to set |
- Returns
- True if url was succesfully parsed and the request is started
| void trippingcyril::net::http::SimpleHTTPSocket::Disconnected |
( |
| ) |
|
|
overrideprotectedvirtual |
| bool trippingcyril::net::http::SimpleHTTPSocket::Get |
( |
const String & |
url | ) |
|
Do a simple HTTP GET request
- Parameters
-
- Returns
- True if url was succesfully parsed and the request is started
| String trippingcyril::net::http::SimpleHTTPSocket::getURL |
( |
| ) |
const |
|
inline |
| bool trippingcyril::net::http::SimpleHTTPSocket::Patch |
( |
const String & |
url, |
|
|
const String & |
patchData, |
|
|
const String & |
type = "" |
|
) |
| |
Do a simple HTTP PATCH request
- Parameters
-
| url | The url to request |
| patchData | the raw patch data to send |
| type | The Content-Type header to set |
- Returns
- True if url was succesfully parsed and the request is started
| bool trippingcyril::net::http::SimpleHTTPSocket::Post |
( |
const String & |
url, |
|
|
const String & |
postData, |
|
|
const String & |
type = "" |
|
) |
| |
Do a simple HTTP POST request
- Parameters
-
| url | The url to request |
| postData | The raw post data to send |
| type | The Content-Type header to set |
- Returns
- True if url was succesfully parsed and the request is started
| bool trippingcyril::net::http::SimpleHTTPSocket::Put |
( |
const String & |
url, |
|
|
const String & |
putData, |
|
|
const String & |
type = "" |
|
) |
| |
Do a simple HTTP PUT request
- Parameters
-
| url | The url to request |
| putData | the raw put data to send |
| type | The Content-Type header to set |
- Returns
- True if url was succesfully parsed and the request is started
| void trippingcyril::net::http::SimpleHTTPSocket::setExtraHeader |
( |
const String & |
key, |
|
|
const String & |
value |
|
) |
| |
|
inline |
Set any custom headers to send with our request, must be called before Get() or Post()
- Parameters
-
| key | The key for your custom header |
| value | The value for your custom header |
| void trippingcyril::net::http::SimpleHTTPSocket::Timeout |
( |
| ) |
|
|
overrideprotectedvirtual |
| const int trippingcyril::net::http::SimpleHTTPSocket::DECOMPESSION_ERROR = -1 |
|
static |
| const int trippingcyril::net::http::SimpleHTTPSocket::GOT_RESPONSE_TOO_EARLY = -3 |
|
static |
Error code for when we get a response before we sent out our full request, which of course shouldn't be happening!
| const int trippingcyril::net::http::SimpleHTTPSocket::TIMEOUT = -2 |
|
static |
The documentation for this class was generated from the following file: