Show More
@@ -90,8 +90,8 b' def decodevaluefromheaders(req, headerpr' | |||||
90 |
|
90 | |||
91 | class webproto(abstractserverproto): |
|
91 | class webproto(abstractserverproto): | |
92 | def __init__(self, req, ui): |
|
92 | def __init__(self, req, ui): | |
93 | self.req = req |
|
93 | self._req = req | |
94 | self.ui = ui |
|
94 | self._ui = ui | |
95 | self.name = 'http' |
|
95 | self.name = 'http' | |
96 |
|
96 | |||
97 | def getargs(self, args): |
|
97 | def getargs(self, args): | |
@@ -110,42 +110,42 b' class webproto(abstractserverproto):' | |||||
110 | return [data[k] for k in keys] |
|
110 | return [data[k] for k in keys] | |
111 |
|
111 | |||
112 | def _args(self): |
|
112 | def _args(self): | |
113 | args = self.req.form.copy() |
|
113 | args = self._req.form.copy() | |
114 | if pycompat.ispy3: |
|
114 | if pycompat.ispy3: | |
115 | args = {k.encode('ascii'): [v.encode('ascii') for v in vs] |
|
115 | args = {k.encode('ascii'): [v.encode('ascii') for v in vs] | |
116 | for k, vs in args.items()} |
|
116 | for k, vs in args.items()} | |
117 | postlen = int(self.req.env.get(r'HTTP_X_HGARGS_POST', 0)) |
|
117 | postlen = int(self._req.env.get(r'HTTP_X_HGARGS_POST', 0)) | |
118 | if postlen: |
|
118 | if postlen: | |
119 | args.update(cgi.parse_qs( |
|
119 | args.update(cgi.parse_qs( | |
120 | self.req.read(postlen), keep_blank_values=True)) |
|
120 | self._req.read(postlen), keep_blank_values=True)) | |
121 | return args |
|
121 | return args | |
122 |
|
122 | |||
123 | argvalue = decodevaluefromheaders(self.req, r'X-HgArg') |
|
123 | argvalue = decodevaluefromheaders(self._req, r'X-HgArg') | |
124 | args.update(cgi.parse_qs(argvalue, keep_blank_values=True)) |
|
124 | args.update(cgi.parse_qs(argvalue, keep_blank_values=True)) | |
125 | return args |
|
125 | return args | |
126 |
|
126 | |||
127 | def getfile(self, fp): |
|
127 | def getfile(self, fp): | |
128 | length = int(self.req.env[r'CONTENT_LENGTH']) |
|
128 | length = int(self._req.env[r'CONTENT_LENGTH']) | |
129 | # If httppostargs is used, we need to read Content-Length |
|
129 | # If httppostargs is used, we need to read Content-Length | |
130 | # minus the amount that was consumed by args. |
|
130 | # minus the amount that was consumed by args. | |
131 | length -= int(self.req.env.get(r'HTTP_X_HGARGS_POST', 0)) |
|
131 | length -= int(self._req.env.get(r'HTTP_X_HGARGS_POST', 0)) | |
132 | for s in util.filechunkiter(self.req, limit=length): |
|
132 | for s in util.filechunkiter(self._req, limit=length): | |
133 | fp.write(s) |
|
133 | fp.write(s) | |
134 |
|
134 | |||
135 | def redirect(self): |
|
135 | def redirect(self): | |
136 | self.oldio = self.ui.fout, self.ui.ferr |
|
136 | self._oldio = self._ui.fout, self._ui.ferr | |
137 | self.ui.ferr = self.ui.fout = stringio() |
|
137 | self._ui.ferr = self._ui.fout = stringio() | |
138 |
|
138 | |||
139 | def restore(self): |
|
139 | def restore(self): | |
140 | val = self.ui.fout.getvalue() |
|
140 | val = self._ui.fout.getvalue() | |
141 | self.ui.ferr, self.ui.fout = self.oldio |
|
141 | self._ui.ferr, self._ui.fout = self._oldio | |
142 | return val |
|
142 | return val | |
143 |
|
143 | |||
144 | def _client(self): |
|
144 | def _client(self): | |
145 | return 'remote:%s:%s:%s' % ( |
|
145 | return 'remote:%s:%s:%s' % ( | |
146 | self.req.env.get('wsgi.url_scheme') or 'http', |
|
146 | self._req.env.get('wsgi.url_scheme') or 'http', | |
147 | urlreq.quote(self.req.env.get('REMOTE_HOST', '')), |
|
147 | urlreq.quote(self._req.env.get('REMOTE_HOST', '')), | |
148 | urlreq.quote(self.req.env.get('REMOTE_USER', ''))) |
|
148 | urlreq.quote(self._req.env.get('REMOTE_USER', ''))) | |
149 |
|
149 | |||
150 | def responsetype(self, prefer_uncompressed): |
|
150 | def responsetype(self, prefer_uncompressed): | |
151 | """Determine the appropriate response type and compression settings. |
|
151 | """Determine the appropriate response type and compression settings. | |
@@ -154,7 +154,7 b' class webproto(abstractserverproto):' | |||||
154 | """ |
|
154 | """ | |
155 | # Determine the response media type and compression engine based |
|
155 | # Determine the response media type and compression engine based | |
156 | # on the request parameters. |
|
156 | # on the request parameters. | |
157 | protocaps = decodevaluefromheaders(self.req, r'X-HgProto').split(' ') |
|
157 | protocaps = decodevaluefromheaders(self._req, r'X-HgProto').split(' ') | |
158 |
|
158 | |||
159 | if '0.2' in protocaps: |
|
159 | if '0.2' in protocaps: | |
160 | # All clients are expected to support uncompressed data. |
|
160 | # All clients are expected to support uncompressed data. | |
@@ -169,11 +169,11 b' class webproto(abstractserverproto):' | |||||
169 | break |
|
169 | break | |
170 |
|
170 | |||
171 | # Now find an agreed upon compression format. |
|
171 | # Now find an agreed upon compression format. | |
172 | for engine in wireproto.supportedcompengines(self.ui, self, |
|
172 | for engine in wireproto.supportedcompengines(self._ui, self, | |
173 | util.SERVERROLE): |
|
173 | util.SERVERROLE): | |
174 | if engine.wireprotosupport().name in compformats: |
|
174 | if engine.wireprotosupport().name in compformats: | |
175 | opts = {} |
|
175 | opts = {} | |
176 | level = self.ui.configint('server', |
|
176 | level = self._ui.configint('server', | |
177 | '%slevel' % engine.name()) |
|
177 | '%slevel' % engine.name()) | |
178 | if level is not None: |
|
178 | if level is not None: | |
179 | opts['level'] = level |
|
179 | opts['level'] = level | |
@@ -186,7 +186,7 b' class webproto(abstractserverproto):' | |||||
186 | # Don't allow untrusted settings because disabling compression or |
|
186 | # Don't allow untrusted settings because disabling compression or | |
187 | # setting a very high compression level could lead to flooding |
|
187 | # setting a very high compression level could lead to flooding | |
188 | # the server's network or CPU. |
|
188 | # the server's network or CPU. | |
189 | opts = {'level': self.ui.configint('server', 'zliblevel')} |
|
189 | opts = {'level': self._ui.configint('server', 'zliblevel')} | |
190 | return HGTYPE, util.compengines['zlib'], opts |
|
190 | return HGTYPE, util.compengines['zlib'], opts | |
191 |
|
191 | |||
192 | def iscmd(cmd): |
|
192 | def iscmd(cmd): |
General Comments 0
You need to be logged in to leave comments.
Login now