def handle_regular_connect(self, f): self.connect_request = True try: self.set_server((f.request.host, f.request.port)) if f.response: resp = f.response else: resp = http.make_connect_response(f.request.data.http_version) self.send_response(resp) if is_ok(resp.status_code): layer = self.ctx.next_layer(self) layer() except ( exceptions.ProtocolException, exceptions.NetlibException ) as e: # HTTPS tasting means that ordinary errors like resolution # and connection errors can happen here. self.send_error_response(502, repr(e)) f.error = flow.Error(str(e)) self.channel.ask("error", f) return False return False
def handle_regular_connect(self, f): self.connect_request = True try: self.set_server((f.request.host, f.request.port)) if f.response: resp = f.response else: resp = http.make_connect_response(f.request.data.http_version) self.send_response(resp) if is_ok(resp.status_code): layer = self.ctx.next_layer(self) layer() except (exceptions.ProtocolException, exceptions.NetlibException) as e: # HTTPS tasting means that ordinary errors like resolution # and connection errors can happen here. self.send_error_response(502, repr(e)) f.error = flow.Error(str(e)) self.channel.ask("error", f) return False return False
def handle_connect_finish(self): if not self.flow.response: self.flow.response = http.make_connect_response(self.flow.request.data.http_version) if 200 <= self.flow.response.status_code < 300: yield SendHttp(ResponseHeaders(self.stream_id, self.flow.response), self.context.client) yield SendHttp(ResponseEndOfMessage(self.stream_id), self.context.client) self.child_layer = self.child_layer or layer.NextLayer(self.context) yield from self.child_layer.handle_event(events.Start()) self._handle_event = self.passthrough else: yield from self.send_response()
def handle_regular_mode_connect(self, request): self.http_authenticated = True self.set_server((request.host, request.port)) self.send_response(http.make_connect_response(request.data.http_version)) layer = self.ctx.next_layer(self) layer()
def test_make_connect_response(): resp = http.make_connect_response('foobar') assert resp.http_version == 'foobar' assert resp.status_code == 200
def handle_regular_mode_connect(self, request): self.http_authenticated = True self.set_server((request.host, request.port)) self.send_response(http.make_connect_response(request.data.http_version)) layer = self.ctx.next_layer(self) layer()