|
Arduino DLNA Server
|
Simple API to process get, put, post, del http requests I tried to use Arduino HttpClient, but I did not manage to extract the mime type from streaming get requests. More...
#include <HttpRequest.h>

Public Member Functions | |
| HttpRequest () | |
| Default constructor. | |
| HttpRequest (ClientType &client) | |
| Constructor with specified client. | |
| ~HttpRequest () override | |
| Destructor. | |
| void | setClient (Client &client) override |
| Sets the client to be used for the requests. | |
| void | setHost (const char *host) override |
| Sets the host name for the requests. | |
| operator bool () override | |
| Checks if the request is valid. | |
| bool | connected () override |
| Checks if connected to the server. | |
| int | available () override |
| Returns the number of available bytes to read. | |
| void | stop () override |
| Stops the connection. | |
| int | post (Url &url, const char *mime, const char *data, int len=-1) override |
| Sends a POST request with data. | |
| int | post (Url &url, size_t len, std::function< size_t(Print &, void *)> writer, const char *mime=nullptr, void *ref=nullptr) override |
| Sends a POST request with streaming body. | |
| int | notify (Url &url, std::function< size_t(Print &, void *)> writer, const char *mime=nullptr, void *ref=nullptr) override |
| Sends a NOTIFY request with streaming body. | |
| int | put (Url &url, const char *mime, const char *data, int len=-1) override |
| Sends a PUT request. | |
| int | del (Url &url, const char *mime=nullptr, const char *data=nullptr, int len=-1) override |
| Sends a DELETE request. | |
| int | get (Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1) override |
| Sends a GET request. | |
| int | head (Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1) override |
| Sends a HEAD request. | |
| int | subscribe (Url &url) override |
| Sends a SUBSCRIBE request. | |
| int | unsubscribe (Url &url, const char *sid) override |
| Sends an UNSUBSCRIBE request. | |
| int | read (uint8_t *str, int len) override |
| Reads reply data. | |
| int | readln (uint8_t *str, int len, bool incl_nl=true) override |
| Reads reply data up to the next new line. | |
| HttpReplyHeader & | reply () override |
| Returns the reply header. | |
| HttpRequestHeader & | request () override |
| Returns the request header. | |
| void | setAgent (const char *agent) override |
| Sets the user agent. | |
| void | setConnection (const char *connection) override |
| Sets the connection type. | |
| void | setAcceptsEncoding (const char *enc) override |
| Sets the accepted encodings. | |
| Client * | client () override |
| Returns the client pointer. | |
| void | setTimeout (int ms) override |
| Sets the timeout. | |
Protected Member Functions | |
| const char * | str (const char *in) |
| Returns an empty string if input is null, otherwise returns the input. | |
| virtual int | connect (const char *ip, uint16_t port) |
| opens a connection to the indicated host | |
| virtual int | process (TinyMethodID action, Url &url, const char *mime, const char *data, int len=-1) |
| sends request and reads the reply_header from the server | |
| virtual int | process (TinyMethodID method, Url &url, size_t len, std::function< size_t(Print &, void *)> writer, const char *mime=nullptr, void *ref=nullptr) |
Protected Attributes | |
| ClientType | default_client |
| Client * | client_ptr = nullptr |
| Url | url |
| HttpRequestHeader | request_header |
| HttpReplyHeader | reply_header |
| HttpChunkReader | chunk_reader {reply_header} |
| Str | host_name |
| const char * | agent = nullptr |
| const char * | connection = CON_CLOSE |
| const char * | accept = ACCEPT_ALL |
| const char * | accept_encoding = nullptr |
Simple API to process get, put, post, del http requests I tried to use Arduino HttpClient, but I did not manage to extract the mime type from streaming get requests.
The functionality is based on the Arduino Client class. The template parameter defines the concrete client that will be managed (e.g. WiFiClient); callers must now provide it explicitly.
| ClientType | concrete Arduino client type that implements the Client interface (e.g. WiFiClient, EthernetClient). |
|
inline |
Default constructor.
|
inlineexplicit |
Constructor with specified client.
|
inlineoverride |
Destructor.
|
inlineoverridevirtual |
Returns the number of available bytes to read.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Returns the client pointer.
Implements tiny_dlna::IHttpRequest.
|
inlineprotectedvirtual |
opens a connection to the indicated host
|
inlineoverridevirtual |
Checks if connected to the server.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sends a DELETE request.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sends a GET request.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sends a HEAD request.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sends a NOTIFY request with streaming body.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Checks if the request is valid.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sends a POST request with data.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sends a POST request with streaming body.
Implements tiny_dlna::IHttpRequest.
|
inlineprotectedvirtual |
sends request and reads the reply_header from the server
|
inlineprotectedvirtual |
Shared implementation for streaming requests. Both POST and NOTIFY (and potentially others) can use this to avoid code duplication.
|
inlineoverridevirtual |
Sends a PUT request.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Reads reply data.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Reads reply data up to the next new line.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Returns the reply header.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Returns the request header.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sets the accepted encodings.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sets the user agent.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sets the client to be used for the requests.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sets the connection type.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sets the host name for the requests.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sets the timeout.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Stops the connection.
Implements tiny_dlna::IHttpRequest.
|
inlineprotected |
Returns an empty string if input is null, otherwise returns the input.
|
inlineoverridevirtual |
Sends a SUBSCRIBE request.
Implements tiny_dlna::IHttpRequest.
|
inlineoverridevirtual |
Sends an UNSUBSCRIBE request.
Implements tiny_dlna::IHttpRequest.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |