Jelajahi Sumber

Use supported HTTP response API for async busy errors

SybexXx 1 hari lalu
induk
melakukan
59497ff730
1 mengubah file dengan 5 tambahan dan 2 penghapusan
  1. 5 2
      code/components/jomjol_wlan/basic_auth.cpp

+ 5 - 2
code/components/jomjol_wlan/basic_auth.cpp

@@ -10,6 +10,7 @@
 #include "freertos/task.h"
 #include "freertos/task.h"
 #include <new>
 #include <new>
 #include <cstring>
 #include <cstring>
+#include <string.h>
 
 
 
 
 #define HTTPD_401 "401 UNAUTHORIZED"
 #define HTTPD_401 "401 UNAUTHORIZED"
@@ -85,7 +86,8 @@ esp_err_t dispatch_camera_http_request_async(httpd_req_t *req,
     if (copyResult != ESP_OK) {
     if (copyResult != ESP_OK) {
         delete work;
         delete work;
         xSemaphoreGive(cameraAsyncRequestSlot);
         xSemaphoreGive(cameraAsyncRequestSlot);
-        httpd_resp_send_err(req, HTTPD_503_SERVICE_UNAVAILABLE, "Could not queue camera request");
+        httpd_resp_set_status(req, "503 Service Unavailable");
+        httpd_resp_sendstr(req, "Could not queue camera request");
         return ESP_OK;
         return ESP_OK;
     }
     }
 
 
@@ -101,8 +103,9 @@ esp_err_t dispatch_camera_http_request_async(httpd_req_t *req,
     if (xTaskCreatePinnedToCore(async_camera_http_request_task, "camera_http",
     if (xTaskCreatePinnedToCore(async_camera_http_request_task, "camera_http",
                                 8 * 1024, work, tskIDLE_PRIORITY + 3,
                                 8 * 1024, work, tskIDLE_PRIORITY + 3,
                                 NULL, 1) != pdPASS) {
                                 NULL, 1) != pdPASS) {
-        httpd_resp_send_err(req, HTTPD_503_SERVICE_UNAVAILABLE, "Could not start camera request worker");
         httpd_req_async_handler_complete(asyncRequest);
         httpd_req_async_handler_complete(asyncRequest);
+        httpd_resp_set_status(req, "503 Service Unavailable");
+        httpd_resp_sendstr(req, "Could not start camera request worker");
         delete work;
         delete work;
         xSemaphoreGive(cameraAsyncRequestSlot);
         xSemaphoreGive(cameraAsyncRequestSlot);
         return ESP_OK;
         return ESP_OK;