mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
httpd: send Connection: close (single-connection uIP mitigation)
Real root cause of the "web login fails from a browser but works from curl": the uIP httpd is built with UIP_CONF_MAX_CONNECTIONS = 1 and uses global response state (outbuf/slen/session), i.e. it serves exactly one TCP connection at a time and closes it after each response - but never advertises that via the Connection header. A browser's HTTP/1.1 client therefore assumes the connection may be persistent and can park it in its keep-alive pool for reuse; a later request sent on that pooled connection hits one the server has already closed, and a POST (unlike a GET) is never retried by the browser, so it can be silently lost this way. This adds "Connection: close" to every response so the browser does not pool and reuse a connection the server is about to drop. On its own this did not fully explain the reported login failures - the actual authentication bug is fixed in the next commit (the Cookie header parsed at a fixed offset) - but it is correct behaviour for a server that only ever handles one connection, and removes one source of dropped requests.
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ extern __xdata char sfp_module_model[2][17];
|
||||
extern __xdata char sfp_module_serial[2][17];
|
||||
extern __xdata uint8_t sfp_options[2];
|
||||
|
||||
__code uint8_t * __code HTTP_RESPONCE_JSON = "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n";
|
||||
__code uint8_t * __code HTTP_RESPONCE_JSON = "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n";
|
||||
__code uint8_t * __code HTTP_RESPONCE_TXT = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n";
|
||||
|
||||
// Convert uint8_t to ascii HEX char push on html-buffer.
|
||||
|
||||
Reference in New Issue
Block a user