MCPcopy Create free account
hub / github.com/EasyIME/PIME / HTTP1Connection

Class HTTP1Connection

python/python3/tornado/http1connection.py:104–705  ·  view source on GitHub ↗

Implements the HTTP/1.x protocol. This class can be on its own for clients, or via `HTTP1ServerConnection` for servers.

Source from the content-addressed store, hash-verified

102
103
104class HTTP1Connection(httputil.HTTPConnection):
105 """Implements the HTTP/1.x protocol.
106
107 This class can be on its own for clients, or via `HTTP1ServerConnection`
108 for servers.
109 """
110
111 def __init__(
112 self,
113 stream: iostream.IOStream,
114 is_client: bool,
115 params: Optional[HTTP1ConnectionParameters] = None,
116 context: Optional[object] = None,
117 ) -> None:
118 """
119 :arg stream: an `.IOStream`
120 :arg bool is_client: client or server
121 :arg params: a `.HTTP1ConnectionParameters` instance or ``None``
122 :arg context: an opaque application-defined object that can be accessed
123 as ``connection.context``.
124 """
125 self.is_client = is_client
126 self.stream = stream
127 if params is None:
128 params = HTTP1ConnectionParameters()
129 self.params = params
130 self.context = context
131 self.no_keep_alive = params.no_keep_alive
132 # The body limits can be altered by the delegate, so save them
133 # here instead of just referencing self.params later.
134 self._max_body_size = (
135 self.params.max_body_size
136 if self.params.max_body_size is not None
137 else self.stream.max_buffer_size
138 )
139 self._body_timeout = self.params.body_timeout
140 # _write_finished is set to True when finish() has been called,
141 # i.e. there will be no more data sent. Data may still be in the
142 # stream's write buffer.
143 self._write_finished = False
144 # True when we have read the entire incoming body.
145 self._read_finished = False
146 # _finish_future resolves when all data has been written and flushed
147 # to the IOStream.
148 self._finish_future = Future() # type: Future[None]
149 # If true, the connection should be closed after this request
150 # (after the response has been written in the server side,
151 # and after it has been read in the client)
152 self._disconnect_on_finish = False
153 self._clear_callbacks()
154 # Save the start lines after we read or write them; they
155 # affect later processing (e.g. 304 responses and HEAD methods
156 # have content-length but no bodies)
157 self._request_start_line = None # type: Optional[httputil.RequestStartLine]
158 self._response_start_line = None # type: Optional[httputil.ResponseStartLine]
159 self._request_headers = None # type: Optional[httputil.HTTPHeaders]
160 # True if we are writing output with chunked encoding.
161 self._chunking_output = False

Callers 4

_create_connectionMethod · 0.90
read_stream_bodyFunction · 0.90
_server_request_loopMethod · 0.85

Calls

no outgoing calls

Tested by 2

read_stream_bodyFunction · 0.72