Fixes Shatterline hanging while loading in game (into the second match).
The game sets 'Connection: close' in additional headers in WinHttpSendRequest(). Server reply does not have any Connection: header and Wine ends up with cached connection. The game does two similar POST requests to the same server one after another. For some reason the second request never gets a reply if reusing the connection. Then, the game never sets WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT and we end up with default '-1' value, so request waits forever for reply on an open connection which never arrives.
As far as my testing goes, both parts are erroneous. Fixing any of those fix the game but it probably makes sense to fix both.
WRT response timeout, MS docs suggest that default WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT is 90sec [1]. The existing test which query default timeout get -1, that's probably why we've got such a default. However, my ad-hoc testing of the actual timeout using a trivial Python webserver from [2] shows that the actual timeout is different: ``` # Python 3 server example from http.server import BaseHTTPRequestHandler, HTTPServer import time
hostName = "0.0.0.0" serverPort = 8080
class MyServer(BaseHTTPRequestHandler): def do_GET(self): time.sleep(100) self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(bytes("<html><head><title>https://pythonbasics.org</title></head>", "utf-8")) self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8")) self.wfile.write(bytes("<body>", "utf-8")) self.wfile.write(bytes("<p>This is an example web server.</p>", "utf-8")) self.wfile.write(bytes("</body></html>", "utf-8"))
if __name__ == "__main__": webServer = HTTPServer((hostName, serverPort), MyServer) print("Server started http://%s:%s" % (hostName, serverPort))
try: webServer.serve_forever() except KeyboardInterrupt: pass
webServer.server_close() print("Server stopped.") ``` I added sleep(100) before sending response and made an ad-hoc test (attache) which shows that the actual timeout is 21sec, at least on Windows 10. The test is apparently too long to run to be included.
WRT closing connection, I added a test which explicitly checks if the connection is closed.
1. https://learn.microsoft.com/en-us/windows/win32/winhttp/option-flags 2. https://pythonbasics.org/webserver/
[test.patch](/uploads/f0a7cce2961a668716ce4db78461442c/test.patch)