mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
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.