This is expected behavior – if you call close()
after shutdown()
on a TCP socket on Linux, the OS simply deletes the file descriptor without triggering an immediate RST. RST is only sent if the client side sends further traffic to the already-closed TCP socket. This can be reproduced locally if you create a TCP connection between a local server / client, then shutdown and immediately close the server-side fd.
It may work differently if your HTTP implementation does not shutdown()
the TCP socket’s write side when an HTTP-level EOF is reached. This may be the case if you tested your Python program locally. However, there isn’t anything in the standard that says one should not call shutdown()
after a L7 EOF is observed, and IMHO is more semantically correct, so that is what our proxy does.