The interface_http.py test can fail in the -- improbable -- case when network reads happen to arrive in smaller chunks (when reading HTTP response from the socket).
Related to #36726 .
All networking code using sockets must not make assumption about the chunking of the incoming/outgoing data, and should be resilient against any chunking. Normally, the chunking of the sends of the writer dictate the chunking of the receives at the reader, but this is not guaranteed by IP/TCP, intermediate networking elements may change the packet structure. In test using sockets on the same host, this is not very likely, but still possible.
This tests reads complete HTTP responses, by checking for the HTTP response code texts ("HTTP/1.1 200"). In doing so, it implicitly assumes that one HTTP response arrives in one recv(). There is no guarantee for this.
This was found -- and can be reproduced -- by using a reproducer patch, that forces all socket sends to use smaller chunking. For the run with the reproducer see #36724 .
The issue is test-code only, the non-test code is correct.
The fix is to follow standard HTTP parsing: read the header until the new line, extract the content length from the header, and read the body of that size. Use repeated receives if needed, until the full response is read.
This fix makes the test more robust, even though a failure due to this issue in CI is very unlikely, but not impossible.