diff --git a/_u_r_l_stream_8h_source.html b/_u_r_l_stream_8h_source.html index 4602b1250..da11c2e2c 100644 --- a/_u_r_l_stream_8h_source.html +++ b/_u_r_l_stream_8h_source.html @@ -373,104 +373,106 @@
325  if (clientSecure != nullptr) {
326  clientSecure->setHandshakeTimeout(handshakeTimeout);
327  }
-
328 
-
329  // Performance optimization for ESP32
-
330  if (!is_power_save) {
-
331  esp_wifi_set_ps(WIFI_PS_NONE);
-
332  }
-
333 #endif
-
334  return true;
-
335  }
-
336 
-
338  template <typename T>
-
339  int process(MethodID action, Url& url, const char* reqMime, T reqData,
-
340  int len = -1) {
-
341  TRACED();
-
342  // keep icy across redirect requests ?
-
343  const char* icy = request.header().get("Icy-MetaData");
-
344 
-
345  int status_code = request.process(action, url, reqMime, reqData, len);
-
346  // redirect
-
347  while (request.reply().isRedirectStatus()) {
-
348  const char* redirect_url = request.reply().get(LOCATION);
-
349  if (redirect_url != nullptr) {
-
350  LOGW("Redirected to: %s", redirect_url);
-
351  url.setUrl(redirect_url);
-
352  Client* p_client = &getClient(url.isSecure());
-
353  p_client->stop();
-
354  request.setClient(*p_client);
-
355  if (icy) {
-
356  request.header().put("Icy-MetaData", icy);
-
357  }
-
358  status_code = request.process(action, url, reqMime, reqData, len);
-
359  } else {
-
360  LOGE("Location is null");
-
361  break;
-
362  }
-
363  }
-
364  return status_code;
-
365  }
-
366 
-
368  Client& getClient(bool isSecure) {
-
369 #ifdef USE_WIFI_CLIENT_SECURE
-
370  if (isSecure) {
-
371  if (clientSecure == nullptr) {
-
372  clientSecure = new WiFiClientSecure();
-
373  clientSecure->setInsecure();
-
374  }
-
375  LOGI("WiFiClientSecure");
-
376  return *clientSecure;
-
377  }
-
378 #endif
-
379 #ifdef USE_WIFI
-
380  if (clientInsecure == nullptr) {
-
381  clientInsecure = new WiFiClient();
-
382  LOGI("WiFiClient");
-
383  }
-
384  return *clientInsecure;
-
385 #else
-
386  if (client == nullptr){
-
387  LOGE("Client not set");
-
388  stop();
-
389  }
-
390  return *client; // to avoid compiler warning
-
391 #endif
-
392  }
-
393 
-
394  inline void fillBuffer() {
-
395  if (isEOS()) {
-
396  // if we consumed all bytes we refill the buffer
-
397  read_size = readBytes(&read_buffer[0], read_buffer_size);
-
398  read_pos = 0;
-
399  }
-
400  }
-
401 
-
402  inline bool isEOS() { return read_pos >= read_size; }
+
328 #endif
+
329 
+
330 #ifdef ESP32
+
331  // Performance optimization for ESP32
+
332  if (!is_power_save) {
+
333  esp_wifi_set_ps(WIFI_PS_NONE);
+
334  }
+
335  return true;
+
336  }
+
337 #endif
+
338 
+
340  template <typename T>
+
341  int process(MethodID action, Url& url, const char* reqMime, T reqData,
+
342  int len = -1) {
+
343  TRACED();
+
344  // keep icy across redirect requests ?
+
345  const char* icy = request.header().get("Icy-MetaData");
+
346 
+
347  int status_code = request.process(action, url, reqMime, reqData, len);
+
348  // redirect
+
349  while (request.reply().isRedirectStatus()) {
+
350  const char* redirect_url = request.reply().get(LOCATION);
+
351  if (redirect_url != nullptr) {
+
352  LOGW("Redirected to: %s", redirect_url);
+
353  url.setUrl(redirect_url);
+
354  Client* p_client = &getClient(url.isSecure());
+
355  p_client->stop();
+
356  request.setClient(*p_client);
+
357  if (icy) {
+
358  request.header().put("Icy-MetaData", icy);
+
359  }
+
360  status_code = request.process(action, url, reqMime, reqData, len);
+
361  } else {
+
362  LOGE("Location is null");
+
363  break;
+
364  }
+
365  }
+
366  return status_code;
+
367  }
+
368 
+
370  Client& getClient(bool isSecure) {
+
371 #ifdef USE_WIFI_CLIENT_SECURE
+
372  if (isSecure) {
+
373  if (clientSecure == nullptr) {
+
374  clientSecure = new WiFiClientSecure();
+
375  clientSecure->setInsecure();
+
376  }
+
377  LOGI("WiFiClientSecure");
+
378  return *clientSecure;
+
379  }
+
380 #endif
+
381 #ifdef USE_WIFI
+
382  if (clientInsecure == nullptr) {
+
383  clientInsecure = new WiFiClient();
+
384  LOGI("WiFiClient");
+
385  }
+
386  return *clientInsecure;
+
387 #else
+
388  if (client == nullptr){
+
389  LOGE("Client not set");
+
390  stop();
+
391  }
+
392  return *client; // to avoid compiler warning
+
393 #endif
+
394  }
+
395 
+
396  inline void fillBuffer() {
+
397  if (isEOS()) {
+
398  // if we consumed all bytes we refill the buffer
+
399  read_size = readBytes(&read_buffer[0], read_buffer_size);
+
400  read_pos = 0;
+
401  }
+
402  }
403 
-
404  bool login() {
-
405 #ifdef USE_WIFI
-
406  if (network != nullptr && password != nullptr &&
-
407  WiFi.status() != WL_CONNECTED) {
-
408  TRACEI();
-
409  WiFi.begin(network, password);
-
410  while (WiFi.status() != WL_CONNECTED) {
-
411  Serial.print(".");
-
412  delay(500);
-
413  }
-
414  Serial.println();
-
415  delay(10);
-
416  return WiFi.status() == WL_CONNECTED;
-
417  }
-
418  return WiFi.status() == WL_CONNECTED;
-
419 #else
-
420  return false;
-
421 #endif
-
422  }
-
423 };
-
424 
-
425 } // namespace audio_tools
+
404  inline bool isEOS() { return read_pos >= read_size; }
+
405 
+
406  bool login() {
+
407 #ifdef USE_WIFI
+
408  if (network != nullptr && password != nullptr &&
+
409  WiFi.status() != WL_CONNECTED) {
+
410  TRACEI();
+
411  WiFi.begin(network, password);
+
412  while (WiFi.status() != WL_CONNECTED) {
+
413  Serial.print(".");
+
414  delay(500);
+
415  }
+
416  Serial.println();
+
417  delay(10);
+
418  return WiFi.status() == WL_CONNECTED;
+
419  }
+
420  return WiFi.status() == WL_CONNECTED;
+
421 #else
+
422  return false;
+
423 #endif
+
424  }
+
425 };
426 
-
427 #endif
+
427 } // namespace audio_tools
+
428 
+
429 #endif
audio_tools::AbstractURLStream
Abstract Base class for all URLStream implementations.
Definition: AbstractURLStream.h:11
audio_tools::Client
Definition: NoArduino.h:139
audio_tools::HttpHeader::setAutoCreateLines
void setAutoCreateLines(bool is_auto_line)
automatically create new lines
Definition: HttpHeader.h:294
@@ -487,8 +489,8 @@
audio_tools::URLStream::begin
virtual bool begin(const char *urlStr, const char *acceptMime=nullptr, MethodID action=GET, const char *reqMime="", const char *reqData="") override
Execute http request: by default we use a GET request.
Definition: URLStream.h:80
audio_tools::URLStream::setTimeout
virtual void setTimeout(int ms)
Defines the client timeout.
Definition: URLStream.h:190
audio_tools::URLStream::setPowerSave
void setPowerSave(bool ps)
Definition: URLStream.h:194
-
audio_tools::URLStream::getClient
Client & getClient(bool isSecure)
Determines the client.
Definition: URLStream.h:368
-
audio_tools::URLStream::process
int process(MethodID action, Url &url, const char *reqMime, T reqData, int len=-1)
Process the Http request and handle redirects.
Definition: URLStream.h:339
+
audio_tools::URLStream::getClient
Client & getClient(bool isSecure)
Determines the client.
Definition: URLStream.h:370
+
audio_tools::URLStream::process
int process(MethodID action, Url &url, const char *reqMime, T reqData, int len=-1)
Process the Http request and handle redirects.
Definition: URLStream.h:341
audio_tools::URLStream::setSSID
void setSSID(const char *ssid) override
Sets the ssid that will be used for logging in (when calling begin)
Definition: URLStream.h:70
audio_tools::URLStream::begin
virtual bool begin(const char *urlStr, const char *acceptMime, MethodID action, const char *reqMime, Stream &reqData, int len=-1)
Execute e.g. http POST request which submits the content as a stream.
Definition: URLStream.h:106
audio_tools::URLStream::waitForData
virtual bool waitForData(int timeout)
waits for some data - returns false if the request has failed
Definition: URLStream.h:233