comparison mercurial/hgweb/request.py @ 36862:1f7d9024674c

hgweb: make parsedrequest part of wsgirequest This is kind of ugly. But an upcoming commit will teach parsedrequest about the input stream. Because the input stream is global state and can't be accessed without side-effects, we need to take actions to ensure that multiple consumers don't read from it independently. The easiest way to do this is for one object to hold a reference to both items having access to the input stream so that when a copy is made, we can remove the attribute from the other instance. So we create our parsed request instance from the wsgirequest constructor and hold a reference to it there. This is better than our new type holding a reference to wsgirequest because all the code for managing access will be temporary and we shouldn't pollute parsedrequest with this ugly history. Differential Revision: https://phab.mercurial-scm.org/D2770
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 10:56:10 -0800
parents 2cdf47e14c30
children da4e2f87167d
comparison
equal deleted inserted replaced
36861:2cdf47e14c30 36862:1f7d9024674c
252 keep_blank_values=1)) 252 keep_blank_values=1))
253 self._start_response = start_response 253 self._start_response = start_response
254 self.server_write = None 254 self.server_write = None
255 self.headers = [] 255 self.headers = []
256 256
257 self.req = parserequestfromenv(wsgienv)
258
257 def respond(self, status, type, filename=None, body=None): 259 def respond(self, status, type, filename=None, body=None):
258 if not isinstance(type, str): 260 if not isinstance(type, str):
259 type = pycompat.sysstr(type) 261 type = pycompat.sysstr(type)
260 if self._start_response is not None: 262 if self._start_response is not None:
261 self.headers.append((r'Content-Type', type)) 263 self.headers.append((r'Content-Type', type))