MCPcopy
hub / github.com/tornadoweb/tornado / HTTP1Connection

Class HTTP1Connection

tornado/http1connection.py:109–704  ·  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

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