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