Mercurial > hg-stable
comparison tests/get-with-headers.py @ 47582:6bceecb28806
windows: make sure we fully read and cleanly close the connection
Maybe this will prevent server on Windows to sometimes complains about the
client closing the connection too soon. So we make sure we read everything and
we officially close the connection.
Hopefully Windows will be happier and the test will stop being flaky.
Differential Revision: https://phab.mercurial-scm.org/D11073
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 10 Jul 2021 17:19:07 +0200 |
parents | 23f5ed6dbcb1 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
47581:28a914b3d4ce | 47582:6bceecb28806 |
---|---|
82 if response.getheader(h, None) is not None: | 82 if response.getheader(h, None) is not None: |
83 stdout.write( | 83 stdout.write( |
84 b"%s: %s\n" | 84 b"%s: %s\n" |
85 % (h.encode('ascii'), response.getheader(h).encode('ascii')) | 85 % (h.encode('ascii'), response.getheader(h).encode('ascii')) |
86 ) | 86 ) |
87 if not headeronly: | 87 if headeronly: |
88 # still read the body to prevent windows to be unhappy about that | |
89 # (this might some flakyness in test-hgweb-filelog.t on Windows) | |
90 data = response.read() | |
91 else: | |
88 stdout.write(b'\n') | 92 stdout.write(b'\n') |
89 data = response.read() | 93 data = response.read() |
90 | 94 |
91 if args.bodyfile: | 95 if args.bodyfile: |
92 bodyfh = open(args.bodyfile, 'wb') | 96 bodyfh = open(args.bodyfile, 'wb') |
110 bodyfh.close() | 114 bodyfh.close() |
111 | 115 |
112 if twice and response.getheader('ETag', None): | 116 if twice and response.getheader('ETag', None): |
113 tag = response.getheader('ETag') | 117 tag = response.getheader('ETag') |
114 | 118 |
119 # further try to please the windows-flakyness deity | |
120 conn.close() | |
121 | |
115 return response.status | 122 return response.status |
116 | 123 |
117 | 124 |
118 status = request(args.host, args.path, args.show) | 125 status = request(args.host, args.path, args.show) |
119 if twice: | 126 if twice: |