Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHG0bc771bba220: wireprotoserver: remove unused argument from _handlehttperror()
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
durin42 |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/wireprotoserver.py (6 lines) |
# The "cmd" query string argument is only valid on the root path of the | # The "cmd" query string argument is only valid on the root path of the | ||||
# repo. e.g. ``/?cmd=foo``, ``/repo?cmd=foo``. URL paths within the repo | # repo. e.g. ``/?cmd=foo``, ``/repo?cmd=foo``. URL paths within the repo | ||||
# like ``/blah?cmd=foo`` are not allowed. So don't recognize the request | # like ``/blah?cmd=foo`` are not allowed. So don't recognize the request | ||||
# in this case. We send an HTTP 404 for backwards compatibility reasons. | # in this case. We send an HTTP 404 for backwards compatibility reasons. | ||||
if req.dispatchpath: | if req.dispatchpath: | ||||
res = _handlehttperror( | res = _handlehttperror( | ||||
hgwebcommon.ErrorResponse(hgwebcommon.HTTP_NOT_FOUND), wsgireq, | hgwebcommon.ErrorResponse(hgwebcommon.HTTP_NOT_FOUND), wsgireq, | ||||
req, cmd) | req) | ||||
return True, res | return True, res | ||||
proto = httpv1protocolhandler(wsgireq, req, repo.ui, | proto = httpv1protocolhandler(wsgireq, req, repo.ui, | ||||
lambda perm: checkperm(rctx, wsgireq, perm)) | lambda perm: checkperm(rctx, wsgireq, perm)) | ||||
# The permissions checker should be the only thing that can raise an | # The permissions checker should be the only thing that can raise an | ||||
# ErrorResponse. It is kind of a layer violation to catch an hgweb | # ErrorResponse. It is kind of a layer violation to catch an hgweb | ||||
# exception here. So consider refactoring into a exception type that | # exception here. So consider refactoring into a exception type that | ||||
# is associated with the wire protocol. | # is associated with the wire protocol. | ||||
try: | try: | ||||
res = _callhttp(repo, wsgireq, req, proto, cmd) | res = _callhttp(repo, wsgireq, req, proto, cmd) | ||||
except hgwebcommon.ErrorResponse as e: | except hgwebcommon.ErrorResponse as e: | ||||
res = _handlehttperror(e, wsgireq, req, cmd) | res = _handlehttperror(e, wsgireq, req) | ||||
return True, res | return True, res | ||||
def _httpresponsetype(ui, req, prefer_uncompressed): | def _httpresponsetype(ui, req, prefer_uncompressed): | ||||
"""Determine the appropriate response type and compression settings. | """Determine the appropriate response type and compression settings. | ||||
Returns a tuple of (mediatype, compengine, engineopts). | Returns a tuple of (mediatype, compengine, engineopts). | ||||
""" | """ | ||||
wsgireq.respond(HTTP_OK, HGTYPE, body=rsp) | wsgireq.respond(HTTP_OK, HGTYPE, body=rsp) | ||||
return [] | return [] | ||||
elif isinstance(rsp, wireprototypes.ooberror): | elif isinstance(rsp, wireprototypes.ooberror): | ||||
rsp = rsp.message | rsp = rsp.message | ||||
wsgireq.respond(HTTP_OK, HGERRTYPE, body=rsp) | wsgireq.respond(HTTP_OK, HGERRTYPE, body=rsp) | ||||
return [] | return [] | ||||
raise error.ProgrammingError('hgweb.protocol internal failure', rsp) | raise error.ProgrammingError('hgweb.protocol internal failure', rsp) | ||||
def _handlehttperror(e, wsgireq, req, cmd): | def _handlehttperror(e, wsgireq, req): | ||||
"""Called when an ErrorResponse is raised during HTTP request processing.""" | """Called when an ErrorResponse is raised during HTTP request processing.""" | ||||
# Clients using Python's httplib are stateful: the HTTP client | # Clients using Python's httplib are stateful: the HTTP client | ||||
# won't process an HTTP response until all request data is | # won't process an HTTP response until all request data is | ||||
# sent to the server. The intent of this code is to ensure | # sent to the server. The intent of this code is to ensure | ||||
# we always read HTTP request data from the client, thus | # we always read HTTP request data from the client, thus | ||||
# ensuring httplib transitions to a state that allows it to read | # ensuring httplib transitions to a state that allows it to read | ||||
# the HTTP response. In other words, it helps prevent deadlocks | # the HTTP response. In other words, it helps prevent deadlocks |