8 #include "WiFiClient.h"
59 virtual int post(
Url &
url,
const char *mime,
const char *data,
int len = -1) {
64 virtual int put(
Url &
url,
const char *mime,
const char *data,
int len = -1) {
69 virtual int del(
Url &
url,
const char *mime =
nullptr,
70 const char *data =
nullptr,
int len = -1) {
75 virtual int get(
Url &
url,
const char *acceptMime =
nullptr,
76 const char *data =
nullptr,
int len = -1) {
82 virtual int head(
Url &
url,
const char *acceptMime =
nullptr,
83 const char *data =
nullptr,
int len = -1) {
100 virtual int readln(uint8_t *
str,
int len,
bool incl_nl =
true) {
138 const char *
str(
const char *in) {
return in ==
nullptr ?
"" : in; }
141 virtual int connect(
const char *ip, uint16_t port) {
143 return this->client_ptr->connect(ip, port);
148 const char *data,
int len = -1) {
151 sprintf(msg,
"connecting to host %s port %d",
url.
host(),
url.
port());
162 if (len == -1 && data !=
nullptr) {
171 if (
agent !=
nullptr) {
177 if (mime !=
nullptr) {
188 client_ptr->write((
const uint8_t *)data, len);
Http might reply with chunks. So we need to dechunk the data. see https://en.wikipedia....
Definition: HttpChunkReader.h:13
void open(Client &client)
Definition: HttpChunkReader.h:28
virtual int read(Client &client, uint8_t *str, int len)
Definition: HttpChunkReader.h:35
virtual int readln(Client &client, uint8_t *str, int len, bool incl_nl=true)
Definition: HttpChunkReader.h:55
int available()
Definition: HttpChunkReader.h:73
virtual int readlnInternal(Stream &client, uint8_t *str, int len, bool incl_nl=true)
Definition: HttpLineReader.h:18
Simple API to process get, put, post, del http requests I tried to use Arduino HttpClient,...
Definition: HttpRequest.h:21
virtual int available()
Definition: HttpRequest.h:47
Url url
Definition: HttpRequest.h:128
const char * agent
Definition: HttpRequest.h:133
virtual HttpRequestHeader & request()
Definition: HttpRequest.h:111
virtual HttpReplyHeader & reply()
Definition: HttpRequest.h:109
HttpReplyHeader reply_header
Definition: HttpRequest.h:130
const char * accept
Definition: HttpRequest.h:135
HttpRequestHeader request_header
Definition: HttpRequest.h:129
Str host_name
Definition: HttpRequest.h:132
virtual int put(Url &url, const char *mime, const char *data, int len=-1)
Definition: HttpRequest.h:64
virtual int get(Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
Definition: HttpRequest.h:75
virtual void setAcceptsEncoding(const char *enc)
Definition: HttpRequest.h:119
virtual void setAgent(const char *agent)
Definition: HttpRequest.h:113
HttpRequest()
Definition: HttpRequest.h:23
const char * accept_encoding
Definition: HttpRequest.h:136
virtual bool connected()
Definition: HttpRequest.h:45
virtual void setConnection(const char *connection)
Definition: HttpRequest.h:115
Client * client()
Definition: HttpRequest.h:123
void setHost(const char *host)
Definition: HttpRequest.h:38
virtual int head(Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
Definition: HttpRequest.h:82
HttpRequest(Client &client)
Definition: HttpRequest.h:29
const char * str(const char *in)
Definition: HttpRequest.h:138
virtual int post(Url &url, const char *mime, const char *data, int len=-1)
Definition: HttpRequest.h:59
virtual int readln(uint8_t *str, int len, bool incl_nl=true)
Definition: HttpRequest.h:100
Client * client_ptr
Definition: HttpRequest.h:127
const char * connection
Definition: HttpRequest.h:134
virtual int process(TinyMethodID action, Url &url, const char *mime, const char *data, int len=-1)
Definition: HttpRequest.h:147
virtual int del(Url &url, const char *mime=nullptr, const char *data=nullptr, int len=-1)
Definition: HttpRequest.h:69
virtual int connect(const char *ip, uint16_t port)
Definition: HttpRequest.h:141
WiFiClient default_client
Definition: HttpRequest.h:126
virtual void stop()
Definition: HttpRequest.h:54
HttpChunkReader chunk_reader
Definition: HttpRequest.h:131
virtual int read(uint8_t *str, int len)
Definition: HttpRequest.h:90
void setClient(Client &client)
Definition: HttpRequest.h:34
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
virtual void add(int value)
adds a int value
Definition: StrView.h:130
virtual bool isEmpty()
checks if the string is empty
Definition: StrView.h:373
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy...
Definition: Str.h:22
const char * c_str()
provides the string value as const char*
Definition: Str.h:188
URL parser which breaks a full url string up into its individual parts.
Definition: Url.h:18
const char * path()
Definition: Url.h:47
int port()
Definition: Url.h:51
const char * url()
Definition: Url.h:46
const char * host()
Definition: Url.h:48
Definition: Allocator.h:6
const char * CONTENT_TYPE
Definition: HttpHeader.h:16
@ DlnaInfo
Definition: Logger.h:16
const char * CONTENT_LENGTH
Definition: HttpHeader.h:17
const char * CON_CLOSE
Definition: HttpHeader.h:19
const char * HOST_C
Definition: HttpHeader.h:29
TinyMethodID
Definition: HttpHeader.h:35
@ T_DELETE
Definition: HttpHeader.h:41
@ T_HEAD
Definition: HttpHeader.h:38
@ T_GET
Definition: HttpHeader.h:37
@ T_PUT
Definition: HttpHeader.h:40
@ T_POST
Definition: HttpHeader.h:39
const char * ACCEPT
Definition: HttpHeader.h:23
const char * ACCEPT_ENCODING
Definition: HttpHeader.h:30
LoggerClass DlnaLogger
Definition: Logger.cpp:5
const char * ACCEPT_ALL
Definition: HttpHeader.h:24
const char * USER_AGENT
Definition: HttpHeader.h:26
const char * CONNECTION
Definition: HttpHeader.h:18