arduino-audio-tools
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
HttpRequest Class Reference

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 (Client &client)
 
void addRequestHeader (const char *header, const char *value)
 Adds/Updates a request header.
 
virtual int available ()
 
Clientclient ()
 
virtual bool connected ()
 
size_t contentLength ()
 
virtual int del (Url &url, const char *mime=nullptr, const char *data=nullptr, int len=-1)
 http del
 
virtual int get (Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
 http get
 
virtual int head (Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
 http head
 
virtual HttpRequestHeaderheader ()
 provides access to the request header
 
bool isChunked ()
 we are sending the data chunked
 
bool isReady ()
 
 operator bool ()
 
virtual int post (Url &url, const char *mime, const char *data, int len=-1)
 http post
 
virtual int post (Url &url, const char *mime, Stream &data, int len=-1)
 http post
 
virtual int process (MethodID action, Url &url, const char *mime, const char *data, int lenData=-1)
 
virtual int process (MethodID action, Url &url, const char *mime, Stream &stream, int len=-1)
 
virtual bool processBegin (MethodID action, Url &url, const char *mime, int lenData=-1)
 starts http request processing
 
virtual int processEnd ()
 Ends the http request processing and returns the status code.
 
virtual void processWrite (Stream &stream)
 Writes (Posts) the data of the indicated stream after calling processBegin.
 
virtual int put (Url &url, const char *mime, const char *data, int len=-1)
 http put
 
virtual int put (Url &url, const char *mime, Stream &data, int len=-1)
 http put
 
virtual int read (uint8_t *str, int len)
 
size_t readBytesUntil (char terminator, char *buffer, size_t length)
 
virtual int readln (uint8_t *str, int len, bool incl_nl=true)
 
virtual HttpReplyHeaderreply ()
 
virtual void setAcceptMime (const char *mime)
 
virtual void setAcceptsEncoding (const char *enc)
 
virtual void setAgent (const char *agent)
 Defines the agent.
 
void setClient (Client &client)
 
virtual void setConnection (const char *connection)
 
void setHost (const char *host)
 
void setOnConnectCallback (void(*callback)(HttpRequest &request, Url &url, HttpRequestHeader &request_header))
 Callback which allows you to add additional paramters dynamically.
 
void setTimeout (int timeoutMs)
 Defines the client timeout in ms.
 
virtual void stop ()
 
virtual size_t write (uint8_t *data, size_t len)
 

Protected Member Functions

virtual int connect (const char *ip, uint16_t port, int32_t timeout)
 

Protected Attributes

const char * accept = ACCEPT_ALL
 
const char * accept_encoding = IDENTITY
 
const char * agent = nullptr
 
HttpChunkReader chunk_reader = HttpChunkReader(reply_header)
 
Clientclient_ptr = nullptr
 
int32_t clientTimeout = URL_CLIENT_TIMEOUT
 
const char * connection = CON_KEEP_ALIVE
 
const char * host_name = nullptr
 
void(* http_connect_callback )(HttpRequest &request, Url &url, HttpRequestHeader &request_header) = nullptr
 
bool is_ready = false
 
HttpReplyHeader reply_header
 
HttpRequestHeader request_header
 
Url url
 

Friends

class URLStream
 

Detailed Description

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.

Author
Phil Schatzmann

Member Function Documentation

◆ isReady()

bool isReady ( )
inline

returns true when the request has completed and ready for the data to be requested

◆ write()

virtual size_t write ( uint8_t *  data,
size_t  len 
)
inlinevirtual

Write data to the client: can be used to post data after calling processBegin


The documentation for this class was generated from the following file: