146 # there are no other known users, so with any luck we can discard this |
146 # there are no other known users, so with any luck we can discard this |
147 # hook if remotefilelog becomes a first-party extension. |
147 # hook if remotefilelog becomes a first-party extension. |
148 def iscmd(cmd): |
148 def iscmd(cmd): |
149 return cmd in wireproto.commands |
149 return cmd in wireproto.commands |
150 |
150 |
151 def handlewsgirequest(rctx, wsgireq, req, res, checkperm): |
151 def handlewsgirequest(rctx, req, res, checkperm): |
152 """Possibly process a wire protocol request. |
152 """Possibly process a wire protocol request. |
153 |
153 |
154 If the current request is a wire protocol request, the request is |
154 If the current request is a wire protocol request, the request is |
155 processed by this function. |
155 processed by this function. |
156 |
156 |
157 ``wsgireq`` is a ``wsgirequest`` instance. |
|
158 ``req`` is a ``parsedrequest`` instance. |
157 ``req`` is a ``parsedrequest`` instance. |
159 ``res`` is a ``wsgiresponse`` instance. |
158 ``res`` is a ``wsgiresponse`` instance. |
160 |
159 |
161 Returns a bool indicating if the request was serviced. If set, the caller |
160 Returns a bool indicating if the request was serviced. If set, the caller |
162 should stop processing the request, as a response has already been issued. |
161 should stop processing the request, as a response has already been issued. |
195 # is mostly for BC for now. |
194 # is mostly for BC for now. |
196 res.setbodybytes('0\n%s\n' % b'Not Found') |
195 res.setbodybytes('0\n%s\n' % b'Not Found') |
197 return True |
196 return True |
198 |
197 |
199 proto = httpv1protocolhandler(req, repo.ui, |
198 proto = httpv1protocolhandler(req, repo.ui, |
200 lambda perm: checkperm(rctx, wsgireq, perm)) |
199 lambda perm: checkperm(rctx, req, perm)) |
201 |
200 |
202 # The permissions checker should be the only thing that can raise an |
201 # The permissions checker should be the only thing that can raise an |
203 # ErrorResponse. It is kind of a layer violation to catch an hgweb |
202 # ErrorResponse. It is kind of a layer violation to catch an hgweb |
204 # exception here. So consider refactoring into a exception type that |
203 # exception here. So consider refactoring into a exception type that |
205 # is associated with the wire protocol. |
204 # is associated with the wire protocol. |