Skip to content
Myr

Improve HTTP protocol detection (#107)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by GitHub · parent 5326cd1 · Browse files · 1 file+5 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−4 removed

  • other:+5 added−4 removed

1 file+5 added−4 removed

modified:http3/dispatch/http11.py+5 added-4 removed
47 unmodified lines
4849 await self._send_request(request, timeout)50 task, args = self._send_request_data, [request.stream(), timeout]51 async with self.backend.background_manager(task, args=args):52 status_code, headers = await self._receive_response(timeout)52 http_version, status_code, headers = await self._receive_response(timeout)53 content = self._receive_response_data(timeout)5455 return AsyncResponse(56 status_code=status_code,57 protocol="HTTP/1.1",57 protocol=http_version,58 headers=headers,59 content=content,60 on_close=self.response_closed,61 request=request,
56 unmodified lines
118 await self.writer.write(bytes_to_send, timeout)119120 async def _receive_response(121 self, timeout: TimeoutConfig = None122 ) -> typing.Tuple[int, typing.List[typing.Tuple[bytes, bytes]]]:122 ) -> typing.Tuple[str, int, typing.List[typing.Tuple[bytes, bytes]]]:123 """124 Read the response status and headers from the network.125 """126 while True:
5 unmodified lines
132 continue133 else:134 assert isinstance(event, h11.Response)135 break136 http_version = "HTTP/%s" % event.http_version.decode("latin-1", errors="ignore")136 return (event.status_code, event.headers)137 return (http_version, event.status_code, event.headers)138139 async def _receive_response_data(140 self, timeout: TimeoutConfig = None141 ) -> typing.AsyncIterator[bytes]:
46 unmodified lines