Show More
@@ -292,8 +292,9 b' def _callhttp(repo, req, proto, cmd):' | |||
|
292 | 292 | req.respond(HTTP_OK, HGTYPE, body=rsp) |
|
293 | 293 | return [] |
|
294 | 294 | elif isinstance(rsp, wireproto.pusherr): |
|
295 | # drain the incoming bundle | |
|
295 | # This is the httplib workaround documented in _handlehttperror(). | |
|
296 | 296 | req.drain() |
|
297 | ||
|
297 | 298 | proto.restore() |
|
298 | 299 | rsp = '0\n%s\n' % rsp.res |
|
299 | 300 | req.respond(HTTP_OK, HGTYPE, body=rsp) |
@@ -306,16 +307,28 b' def _callhttp(repo, req, proto, cmd):' | |||
|
306 | 307 | |
|
307 | 308 | def _handlehttperror(e, req, cmd): |
|
308 | 309 | """Called when an ErrorResponse is raised during HTTP request processing.""" |
|
309 | # A client that sends unbundle without 100-continue will | |
|
310 | # break if we respond early. | |
|
311 | if (cmd == 'unbundle' and | |
|
310 | ||
|
311 | # Clients using Python's httplib are stateful: the HTTP client | |
|
312 | # won't process an HTTP response until all request data is | |
|
313 | # sent to the server. The intent of this code is to ensure | |
|
314 | # we always read HTTP request data from the client, thus | |
|
315 | # ensuring httplib transitions to a state that allows it to read | |
|
316 | # the HTTP response. In other words, it helps prevent deadlocks | |
|
317 | # on clients using httplib. | |
|
318 | ||
|
319 | if (req.env[r'REQUEST_METHOD'] == r'POST' and | |
|
320 | # But not if Expect: 100-continue is being used. | |
|
312 | 321 | (req.env.get('HTTP_EXPECT', |
|
313 | 322 | '').lower() != '100-continue') or |
|
323 | # Or the non-httplib HTTP library is being advertised by | |
|
324 | # the client. | |
|
314 | 325 | req.env.get('X-HgHttp2', '')): |
|
315 | 326 | req.drain() |
|
316 | 327 | else: |
|
317 | 328 | req.headers.append((r'Connection', r'Close')) |
|
318 | 329 | |
|
330 | # TODO This response body assumes the failed command was | |
|
331 | # "unbundle." That assumption is not always valid. | |
|
319 | 332 | req.respond(e, HGTYPE, body='0\n%s\n' % e) |
|
320 | 333 | |
|
321 | 334 | return '' |
General Comments 0
You need to be logged in to leave comments.
Login now