WebServer Request processed twice
Posted: Sat Aug 26, 2023 5:07 pm
I built a web server on an ESP32 device using the Arduino-ESP32 WebServer.h library. The server works great, but I noticed that every request that comes in through the browser processes twice on the server. When I send the same request from Postman, it only processes once. I tried this on a variety of browsers and I get the same result.
I found this article for ESP8266: https://github.com/esp8266/Arduino/issues/6181 that indicates its an issue with Chrome and changing the request type to POST instead of GET should fix the problem. I tried that as well and it didn't help.
Looking at the requests, I updated my Arduino code to write the `server.method()` value to the Serial Monitor and I get the following:
```
WiFi connected
IP address: 192.168.86.230
Web Server running on core 0
Web server: MDNS responder started
LED Management running on core 1
Web server: HTTP server started
Web server: Off
Method: 6
Sent Success response
Web server: Off
Method: 3
Sent Success response
```
So it looks like the web server sees my one request come in with two different request method values.
When I send from Postman the request has a method of 3. What does that mean? I can't find a reference in the code for what server.method() values of 3 and 6 mean.
I found this article for ESP8266: https://github.com/esp8266/Arduino/issues/6181 that indicates its an issue with Chrome and changing the request type to POST instead of GET should fix the problem. I tried that as well and it didn't help.
Looking at the requests, I updated my Arduino code to write the `server.method()` value to the Serial Monitor and I get the following:
```
WiFi connected
IP address: 192.168.86.230
Web Server running on core 0
Web server: MDNS responder started
LED Management running on core 1
Web server: HTTP server started
Web server: Off
Method: 6
Sent Success response
Web server: Off
Method: 3
Sent Success response
```
So it looks like the web server sees my one request come in with two different request method values.
When I send from Postman the request has a method of 3. What does that mean? I can't find a reference in the code for what server.method() values of 3 and 6 mean.