From 779aef401e29e4a98102023a40e4ae06a855c1ea Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Thu, 27 Oct 2022 17:01:29 +0530 Subject: [PATCH] esp_prov: added support for session cookie in SoftAP mode --- tools/esp_prov/transport/transport_http.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/esp_prov/transport/transport_http.py b/tools/esp_prov/transport/transport_http.py index 5f0b04b1bd..a76a1a5b7d 100644 --- a/tools/esp_prov/transport/transport_http.py +++ b/tools/esp_prov/transport/transport_http.py @@ -39,6 +39,13 @@ class Transport_HTTP(Transport): try: self.conn.request('POST', path, tobytes(data), self.headers) response = self.conn.getresponse() + # While establishing a session, the device sends the Set-Cookie header + # with value 'session=cookie_session_id' in its first response of the session to the tool. + # To maintain the same session, successive requests from the tool should include + # an additional 'Cookie' header with the above recieved value. + for hdr_key, hdr_val in response.getheaders(): + if hdr_key == 'Set-Cookie': + self.headers['Cookie'] = hdr_val if response.status == 200: return response.read().decode('latin-1') except Exception as err: