mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
file_serving example: Demonstrate use of connection close header from request headers
Closes: https://github.com/espressif/esp-idf/issues/5775
This commit is contained in:
@@ -277,6 +277,9 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
||||
ESP_LOGI(TAG, "File sending complete");
|
||||
|
||||
/* Respond with an empty chunk to signal HTTP response completion */
|
||||
#ifdef CONFIG_EXAMPLE_HTTPD_CONN_CLOSE_HEADER
|
||||
httpd_resp_set_hdr(req, "Connection", "close");
|
||||
#endif
|
||||
httpd_resp_send_chunk(req, NULL, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -388,6 +391,9 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
|
||||
/* Redirect onto root to see the updated file list */
|
||||
httpd_resp_set_status(req, "303 See Other");
|
||||
httpd_resp_set_hdr(req, "Location", "/");
|
||||
#ifdef CONFIG_EXAMPLE_HTTPD_CONN_CLOSE_HEADER
|
||||
httpd_resp_set_hdr(req, "Connection", "close");
|
||||
#endif
|
||||
httpd_resp_sendstr(req, "File uploaded successfully");
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -429,6 +435,9 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
|
||||
/* Redirect onto root to see the updated file list */
|
||||
httpd_resp_set_status(req, "303 See Other");
|
||||
httpd_resp_set_hdr(req, "Location", "/");
|
||||
#ifdef CONFIG_EXAMPLE_HTTPD_CONN_CLOSE_HEADER
|
||||
httpd_resp_set_hdr(req, "Connection", "close");
|
||||
#endif
|
||||
httpd_resp_sendstr(req, "File deleted successfully");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user