Details
Details
- Reviewers
yuja - Group Reviewers
hg-reviewers - Commits
- rHGb2601c5977a4: hgweb: more "http headers are native strs" cleanup
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
yuja |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/hgweb/hgweb_mod.py (2 lines) | |||
M | mercurial/hgweb/protocol.py (4 lines) | |||
M | mercurial/hgweb/server.py (4 lines) |
# A client that sends unbundle without 100-continue will | # A client that sends unbundle without 100-continue will | ||||
# break if we respond early. | # break if we respond early. | ||||
if (cmd == 'unbundle' and | if (cmd == 'unbundle' and | ||||
(req.env.get('HTTP_EXPECT', | (req.env.get('HTTP_EXPECT', | ||||
'').lower() != '100-continue') or | '').lower() != '100-continue') or | ||||
req.env.get('X-HgHttp2', '')): | req.env.get('X-HgHttp2', '')): | ||||
req.drain() | req.drain() | ||||
else: | else: | ||||
req.headers.append(('Connection', 'Close')) | req.headers.append((r'Connection', r'Close')) | ||||
req.respond(inst, protocol.HGTYPE, | req.respond(inst, protocol.HGTYPE, | ||||
body='0\n%s\n' % inst) | body='0\n%s\n' % inst) | ||||
return '' | return '' | ||||
# translate user-visible url structure to internal structure | # translate user-visible url structure to internal structure | ||||
args = query.split('/', 2) | args = query.split('/', 2) | ||||
if r'cmd' not in req.form and args and args[0]: | if r'cmd' not in req.form and args and args[0]: |
args.update(cgi.parse_qs( | args.update(cgi.parse_qs( | ||||
self.req.read(postlen), keep_blank_values=True)) | self.req.read(postlen), keep_blank_values=True)) | ||||
return args | return args | ||||
argvalue = decodevaluefromheaders(self.req, 'X-HgArg') | argvalue = decodevaluefromheaders(self.req, 'X-HgArg') | ||||
args.update(cgi.parse_qs(argvalue, keep_blank_values=True)) | args.update(cgi.parse_qs(argvalue, keep_blank_values=True)) | ||||
return args | return args | ||||
def getfile(self, fp): | def getfile(self, fp): | ||||
length = int(self.req.env['CONTENT_LENGTH']) | length = int(self.req.env[r'CONTENT_LENGTH']) | ||||
# If httppostargs is used, we need to read Content-Length | # If httppostargs is used, we need to read Content-Length | ||||
# minus the amount that was consumed by args. | # minus the amount that was consumed by args. | ||||
length -= int(self.req.env.get('HTTP_X_HGARGS_POST', 0)) | length -= int(self.req.env.get(r'HTTP_X_HGARGS_POST', 0)) | ||||
for s in util.filechunkiter(self.req, limit=length): | for s in util.filechunkiter(self.req, limit=length): | ||||
fp.write(s) | fp.write(s) | ||||
def redirect(self): | def redirect(self): | ||||
self.oldio = self.ui.fout, self.ui.ferr | self.oldio = self.ui.fout, self.ui.ferr | ||||
self.ui.ferr = self.ui.fout = stringio() | self.ui.ferr = self.ui.fout = stringio() | ||||
def restore(self): | def restore(self): | ||||
val = self.ui.fout.getvalue() | val = self.ui.fout.getvalue() | ||||
self.ui.ferr, self.ui.fout = self.oldio | self.ui.ferr, self.ui.fout = self.oldio |
self.send_header(*h) | self.send_header(*h) | ||||
if h[0].lower() == 'content-length': | if h[0].lower() == 'content-length': | ||||
self.length = int(h[1]) | self.length = int(h[1]) | ||||
if (self.length is None and | if (self.length is None and | ||||
saved_status[0] != common.HTTP_NOT_MODIFIED): | saved_status[0] != common.HTTP_NOT_MODIFIED): | ||||
self._chunked = (not self.close_connection and | self._chunked = (not self.close_connection and | ||||
self.request_version == "HTTP/1.1") | self.request_version == "HTTP/1.1") | ||||
if self._chunked: | if self._chunked: | ||||
self.send_header('Transfer-Encoding', 'chunked') | self.send_header(r'Transfer-Encoding', r'chunked') | ||||
else: | else: | ||||
self.send_header('Connection', 'close') | self.send_header(r'Connection', r'close') | ||||
self.end_headers() | self.end_headers() | ||||
self.sent_headers = True | self.sent_headers = True | ||||
def _start_response(self, http_status, headers, exc_info=None): | def _start_response(self, http_status, headers, exc_info=None): | ||||
code, msg = http_status.split(None, 1) | code, msg = http_status.split(None, 1) | ||||
code = int(code) | code = int(code) | ||||
self.saved_status = http_status | self.saved_status = http_status | ||||
bad_headers = ('connection', 'transfer-encoding') | bad_headers = ('connection', 'transfer-encoding') |