arduino-audio-tools
|
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 *key, const char *value) |
Adds/Updates a request header. | |
virtual int | available () override |
virtual int | availableForWrite () override |
virtual bool | begin () |
Client & | client () |
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 HttpRequestHeader & | header () |
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 HttpReplyHeader & | reply () |
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 () |
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) |
Client * | client_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_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 |
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.
Reimplemented from BaseStream.
Reimplemented from Print.
Reimplemented in UDPStream, A2DPStream, AudioFFTBase, I2SCodecStream, AbstractURLStream, URLStreamESP32, I2SStream, MeasuringStream, ProgressStream, and VolumeStream.
Reimplemented in AudioOutputWithCallback, HLSStream, SPDIFOutput, VS1053Stream, WM8960Stream, ESPNowStream, TimerCallbackAudioStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, AudioFFTBase, AnalogAudioArduino, AnalogAudioStream, MemoryStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, FormatConverterStream, and Pipeline.
|
inlineoverridevirtual |
same as end()
Reimplemented from BaseStream.
Reimplemented from Print.
Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.
|
inline |
returns true when the request has completed and ready for the data to be requested
Implements BaseStream.
Write data to the client: can be used to post data after calling processBegin
Implements BaseStream.
Reimplemented in BufferedTaskStream, and BufferedStream.