|
@@ -1169,6 +1169,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay, bool previewCaptur
|
|
|
uint8_t *responseData = NULL;
|
|
uint8_t *responseData = NULL;
|
|
|
size_t responseLength = 0;
|
|
size_t responseLength = 0;
|
|
|
bool responseInPsram = false;
|
|
bool responseInPsram = false;
|
|
|
|
|
+ bool responseStarted = false;
|
|
|
esp_err_t captureResult = ESP_OK;
|
|
esp_err_t captureResult = ESP_OK;
|
|
|
const int64_t captureStart = esp_timer_get_time();
|
|
const int64_t captureStart = esp_timer_get_time();
|
|
|
|
|
|
|
@@ -1305,6 +1306,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay, bool previewCaptur
|
|
|
}
|
|
}
|
|
|
if (captureResult == ESP_OK)
|
|
if (captureResult == ESP_OK)
|
|
|
{
|
|
{
|
|
|
|
|
+ responseStarted = true;
|
|
|
captureResult = httpd_resp_send(req, reinterpret_cast<const char *>(responseData),
|
|
captureResult = httpd_resp_send(req, reinterpret_cast<const char *>(responseData),
|
|
|
static_cast<ssize_t>(responseLength));
|
|
static_cast<ssize_t>(responseLength));
|
|
|
}
|
|
}
|
|
@@ -1324,18 +1326,16 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay, bool previewCaptur
|
|
|
{
|
|
{
|
|
|
free(responseData);
|
|
free(responseData);
|
|
|
}
|
|
}
|
|
|
|
|
+ responseData = NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ESP_LOGI(TAG, "HTTP JPEG capture: %uKB %ums",
|
|
ESP_LOGI(TAG, "HTTP JPEG capture: %uKB %ums",
|
|
|
static_cast<unsigned int>(responseLength / 1024),
|
|
static_cast<unsigned int>(responseLength / 1024),
|
|
|
static_cast<unsigned int>((captureEnd - captureStart) / 1000));
|
|
static_cast<unsigned int>((captureEnd - captureStart) / 1000));
|
|
|
|
|
|
|
|
- if (captureResult != ESP_OK)
|
|
|
|
|
|
|
+ if (captureResult != ESP_OK && !responseStarted)
|
|
|
{
|
|
{
|
|
|
- // The socket may already have started a response; only send the
|
|
|
|
|
- // fallback status for failures that occurred before response setup.
|
|
|
|
|
- if (responseData == NULL || responseLength == 0)
|
|
|
|
|
- httpd_resp_send_500(req);
|
|
|
|
|
|
|
+ httpd_resp_send_500(req);
|
|
|
}
|
|
}
|
|
|
return captureResult;
|
|
return captureResult;
|
|
|
}
|
|
}
|