diff --git a/_http_request_8h_source.html b/_http_request_8h_source.html index 31588ccbc..77d83c610 100644 --- a/_http_request_8h_source.html +++ b/_http_request_8h_source.html @@ -345,64 +345,66 @@
303  TRACED();
304  // if sending is chunked we terminate with an empty chunk
305  if (isChunked()) {
-
306  write(nullptr, 0);
-
307  }
-
308  LOGI("Request written ... waiting for reply");
-
309  // Commented out because this breaks the RP2040 W
-
310  // client_ptr->flush();
-
311  reply_header.read(*client_ptr);
-
312 
-
313  // if we use chunked tranfer we need to read the first chunked length
-
314  if (reply_header.isChunked()) {
-
315  chunk_reader.open(*client_ptr);
-
316  };
-
317 
-
318  // wait for data
-
319  is_ready = true;
-
320  return reply_header.statusCode();
-
321  }
-
322 
-
324  void setOnConnectCallback(void (*callback)(
-
325  HttpRequest &request, Url &url, HttpRequestHeader &request_header)) {
-
326  http_connect_callback = callback;
-
327  }
-
328 
-
330  void setTimeout(int timeoutMs) { clientTimeout = timeoutMs; }
-
331 
-
333  bool isChunked() { return request_header.isChunked(); }
-
334 
-
335  protected:
-
336  Client *client_ptr = nullptr;
-
337  Url url;
-
338  HttpRequestHeader request_header;
-
339  HttpReplyHeader reply_header;
-
340  HttpChunkReader chunk_reader = HttpChunkReader(reply_header);
-
341  const char *agent = nullptr;
-
342  const char *host_name = nullptr;
-
343  const char *connection = CON_KEEP_ALIVE;
-
344  const char *accept = ACCEPT_ALL;
-
345  const char *accept_encoding = IDENTITY;
-
346  bool is_ready = false;
-
347  int32_t clientTimeout = URL_CLIENT_TIMEOUT; // 60000;
-
348  void (*http_connect_callback)(HttpRequest &request, Url &url,
-
349  HttpRequestHeader &request_header) = nullptr;
-
350  bool is_chunked_output_active = false;
-
351 
-
352  // opens a connection to the indicated host
-
353  virtual int connect(const char *ip, uint16_t port, int32_t timeout) {
-
354  TRACED();
-
355  client_ptr->setTimeout(timeout / 1000); // client timeout is in seconds!
-
356  request_header.setTimeout(timeout);
-
357  reply_header.setTimeout(timeout);
-
358  int is_connected = this->client_ptr->connect(ip, port);
-
359  LOGI("is connected %s with timeout %d", is_connected ? "true" : "false", (int)timeout);
-
360  return is_connected;
-
361  }
-
362 };
-
363 
-
364 } // namespace audio_tools
+
306  if (is_chunked_output_active) client_ptr->println(0, HEX);
+
307  client_ptr->println();
+
308  is_chunked_output_active = false;
+
309  }
+
310  LOGI("Request written ... waiting for reply");
+
311  // Commented out because this breaks the RP2040 W
+
312  // client_ptr->flush();
+
313  reply_header.read(*client_ptr);
+
314 
+
315  // if we use chunked tranfer we need to read the first chunked length
+
316  if (reply_header.isChunked()) {
+
317  chunk_reader.open(*client_ptr);
+
318  };
+
319 
+
320  // wait for data
+
321  is_ready = true;
+
322  return reply_header.statusCode();
+
323  }
+
324 
+
326  void setOnConnectCallback(void (*callback)(
+
327  HttpRequest &request, Url &url, HttpRequestHeader &request_header)) {
+
328  http_connect_callback = callback;
+
329  }
+
330 
+
332  void setTimeout(int timeoutMs) { clientTimeout = timeoutMs; }
+
333 
+
335  bool isChunked() { return request_header.isChunked(); }
+
336 
+
337  protected:
+
338  Client *client_ptr = nullptr;
+
339  Url url;
+
340  HttpRequestHeader request_header;
+
341  HttpReplyHeader reply_header;
+
342  HttpChunkReader chunk_reader = HttpChunkReader(reply_header);
+
343  const char *agent = nullptr;
+
344  const char *host_name = nullptr;
+
345  const char *connection = CON_KEEP_ALIVE;
+
346  const char *accept = ACCEPT_ALL;
+
347  const char *accept_encoding = IDENTITY;
+
348  bool is_ready = false;
+
349  int32_t clientTimeout = URL_CLIENT_TIMEOUT; // 60000;
+
350  void (*http_connect_callback)(HttpRequest &request, Url &url,
+
351  HttpRequestHeader &request_header) = nullptr;
+
352  bool is_chunked_output_active = false;
+
353 
+
354  // opens a connection to the indicated host
+
355  virtual int connect(const char *ip, uint16_t port, int32_t timeout) {
+
356  TRACED();
+
357  client_ptr->setTimeout(timeout / 1000); // client timeout is in seconds!
+
358  request_header.setTimeout(timeout);
+
359  reply_header.setTimeout(timeout);
+
360  int is_connected = this->client_ptr->connect(ip, port);
+
361  LOGI("is connected %s with timeout %d", is_connected ? "true" : "false", (int)timeout);
+
362  return is_connected;
+
363  }
+
364 };
365 
-
366 #endif
+
366 } // namespace audio_tools
+
367 
+
368 #endif
audio_tools::BaseStream
Base class for all Streams. It relies on write(const uint8_t *buffer, size_t size) and readBytes(uint...
Definition: BaseStream.h:34
audio_tools::Client
Definition: NoArduino.h:139
audio_tools::HttpChunkReader
Http might reply with chunks. So we need to dechunk the data. see https://en.wikipedia....
Definition: HttpChunkReader.h:14
@@ -413,8 +415,8 @@
audio_tools::HttpReplyHeader
Reading and Writing of Http Replys.
Definition: HttpHeader.h:448
audio_tools::HttpRequestHeader
Reading and writing of Http Requests.
Definition: HttpHeader.h:389
audio_tools::HttpRequest
Simple API to process get, put, post, del http requests I tried to use Arduino HttpClient,...
Definition: HttpRequest.h:26
-
audio_tools::HttpRequest::setTimeout
void setTimeout(int timeoutMs)
Defines the client timeout in ms.
Definition: HttpRequest.h:330
-
audio_tools::HttpRequest::isChunked
bool isChunked()
we are sending the data chunked
Definition: HttpRequest.h:333
+
audio_tools::HttpRequest::setTimeout
void setTimeout(int timeoutMs)
Defines the client timeout in ms.
Definition: HttpRequest.h:332
+
audio_tools::HttpRequest::isChunked
bool isChunked()
we are sending the data chunked
Definition: HttpRequest.h:335
audio_tools::HttpRequest::post
virtual int post(Url &url, const char *mime, Stream &data, int len=-1)
http post
Definition: HttpRequest.h:83
audio_tools::HttpRequest::get
virtual int get(Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
http get
Definition: HttpRequest.h:108
audio_tools::HttpRequest::processEnd
virtual int processEnd()
Ends the http request processing and returns the status code.
Definition: HttpRequest.h:302
@@ -428,7 +430,7 @@
audio_tools::HttpRequest::put
virtual int put(Url &url, const char *mime, Stream &data, int len=-1)
http put
Definition: HttpRequest.h:95
audio_tools::HttpRequest::head
virtual int head(Url &url, const char *acceptMime=nullptr, const char *data=nullptr, int len=-1)
http head
Definition: HttpRequest.h:116
audio_tools::HttpRequest::post
virtual int post(Url &url, const char *mime, const char *data, int len=-1)
http post
Definition: HttpRequest.h:77
-
audio_tools::HttpRequest::setOnConnectCallback
void setOnConnectCallback(void(*callback)(HttpRequest &request, Url &url, HttpRequestHeader &request_header))
Callback which allows you to add additional paramters dynamically.
Definition: HttpRequest.h:324
+
audio_tools::HttpRequest::setOnConnectCallback
void setOnConnectCallback(void(*callback)(HttpRequest &request, Url &url, HttpRequestHeader &request_header))
Callback which allows you to add additional paramters dynamically.
Definition: HttpRequest.h:326
audio_tools::HttpRequest::isReady
bool isReady()
Definition: HttpRequest.h:185
audio_tools::HttpRequest::addRequestHeader
void addRequestHeader(const char *header, const char *value)
Adds/Updates a request header.
Definition: HttpRequest.h:188
audio_tools::HttpRequest::del
virtual int del(Url &url, const char *mime=nullptr, const char *data=nullptr, int len=-1)
http del
Definition: HttpRequest.h:101
diff --git a/_u_r_l_stream_8h_source.html b/_u_r_l_stream_8h_source.html index 587919493..2d698f5ce 100644 --- a/_u_r_l_stream_8h_source.html +++ b/_u_r_l_stream_8h_source.html @@ -478,7 +478,7 @@
audio_tools::HttpRequestHeader
Reading and writing of Http Requests.
Definition: HttpHeader.h:389
audio_tools::HttpRequest
Simple API to process get, put, post, del http requests I tried to use Arduino HttpClient,...
Definition: HttpRequest.h:26
audio_tools::HttpRequest::header
virtual HttpRequestHeader & header()
provides access to the request header
Definition: HttpRequest.h:157
-
audio_tools::HttpRequest::setOnConnectCallback
void setOnConnectCallback(void(*callback)(HttpRequest &request, Url &url, HttpRequestHeader &request_header))
Callback which allows you to add additional paramters dynamically.
Definition: HttpRequest.h:324
+
audio_tools::HttpRequest::setOnConnectCallback
void setOnConnectCallback(void(*callback)(HttpRequest &request, Url &url, HttpRequestHeader &request_header))
Callback which allows you to add additional paramters dynamically.
Definition: HttpRequest.h:326
audio_tools::HttpRequest::isReady
bool isReady()
Definition: HttpRequest.h:185
audio_tools::StrView::c_str
virtual const char * c_str()
provides the string value as const char*
Definition: StrView.h:379
audio_tools::Stream
Definition: NoArduino.h:125