mirror of
https://github.com/esphome/esphome.git
synced 2026-09-19 02:58:38 +00:00
fixes
This commit is contained in:
@@ -52,13 +52,7 @@ void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
|
||||
ESP_LOGI(TAG, " Password=" LOG_SECRET("'%s'"), psk.c_str());
|
||||
wifi::global_wifi_component->save_wifi_sta(ssid, psk);
|
||||
wifi::global_wifi_component->start_scanning();
|
||||
|
||||
// Add Connection: close header to ensure socket is released immediately
|
||||
// Without this, sockets can stay in TIME_WAIT and exhaust the socket pool
|
||||
auto *response = request->beginResponse(302, ESPHOME_F("text/plain"), ESPHOME_F(""));
|
||||
response->addHeader(ESPHOME_F("Location"), ESPHOME_F("/?save"));
|
||||
response->addHeader(ESPHOME_F("Connection"), ESPHOME_F("close"));
|
||||
request->send(response);
|
||||
request->redirect(ESPHOME_F("/?save"));
|
||||
}
|
||||
|
||||
void CaptivePortal::setup() {
|
||||
|
||||
@@ -242,6 +242,7 @@ void AsyncWebServerRequest::send(int code, const char *content_type, const char
|
||||
void AsyncWebServerRequest::redirect(const std::string &url) {
|
||||
httpd_resp_set_status(*this, "302 Found");
|
||||
httpd_resp_set_hdr(*this, "Location", url.c_str());
|
||||
httpd_resp_set_hdr(*this, "Connection", "close");
|
||||
httpd_resp_send(*this, nullptr, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user