arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | 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>

Inheritance diagram for HttpRequest:
BaseStream Stream Print

Public Member Functions

 HttpRequest (Client &client)
 
void addRequestHeader (const char *key, const char *value)
 Adds/Updates a request header.
 
virtual int available () override
 
virtual int availableForWrite () override
 
virtual bool begin ()
 
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
 
void end () override
 same as end()
 
virtual void flush () override
 
virtual int get (Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
 http get
 
const char * getReplyHeader (const char *key)
 
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 readBytes (uint8_t *str, size_t len) override
 
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 (size_t timeoutMs)
 Defines the client timeout in ms.
 
void setWriteBufferSize (int size)
 
virtual void stop ()
 
size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 

Protected Member Functions

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

Protected Attributes

int _timeout = 10
 
const char * accept = ACCEPT_ALL
 
const char * accept_encoding = IDENTITY
 
const char * agent = nullptr
 
HttpChunkReader chunk_reader = HttpChunkReader(reply_header)
 
Clientclient_ptr = nullptr
 
size_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_chunked_output_active = false
 
bool is_ready = false
 
HttpReplyHeader reply_header
 
HttpRequestHeader request_header
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
Url url
 
int write_buffer_size = MAX_SINGLE_CHARS
 

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

◆ available()

virtual int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ begin()

virtual bool begin ( )
inlinevirtualinherited

◆ end()

void end ( )
inlineoverridevirtual

same as end()

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

Reimplemented from Print.

Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.

◆ isReady()

bool isReady ( )
inline

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

◆ readBytes()

size_t readBytes ( uint8_t *  str,
size_t  len 
)
inlineoverridevirtual

Implements BaseStream.

◆ write() [1/2]

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

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

Implements BaseStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Reimplemented in BufferedTaskStream, and BufferedStream.


The documentation for this class was generated from the following file:
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy