code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def connection_made(self, transport): """ The connection has been made. Here we need to save off our transport, do basic HTTP/2 connection setup, and then start our data writing coroutine. """ self.transport = transport self.conn.initiate_connection() self...
The connection has been made. Here we need to save off our transport, do basic HTTP/2 connection setup, and then start our data writing coroutine.
connection_made
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def window_opened(self, event): """ The flow control window got opened. This is important because it's possible that we were unable to send some WSGI data because the flow control window was too small. If that happens, the sending_loop coroutine starts buffering data. A...
The flow control window got opened. This is important because it's possible that we were unable to send some WSGI data because the flow control window was too small. If that happens, the sending_loop coroutine starts buffering data. As the window gets opened, we need to unbuff...
window_opened
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
async def sending_loop(self): """ A call that loops forever, attempting to send data. This sending loop contains most of the flow-control smarts of this class: it pulls data off of the asyncio queue and then attempts to send it. The difficulties here are all around flow control....
A call that loops forever, attempting to send data. This sending loop contains most of the flow-control smarts of this class: it pulls data off of the asyncio queue and then attempts to send it. The difficulties here are all around flow control. Specifically, a chunk of data ma...
sending_loop
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def request_received(self, event): """ A HTTP/2 request has been received. We need to invoke the WSGI application in a background thread to handle it. """ # First, we are going to want an object to hold all the relevant state # for this request/response. For that, we have...
A HTTP/2 request has been received. We need to invoke the WSGI application in a background thread to handle it.
request_received
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def data_frame_received(self, event): """ Data has been received by WSGI server and needs to be dispatched to a running application. Note that the flow control window is not modified here. That's deliberate: see Stream.__next__ for a longer discussion of why. """ ...
Data has been received by WSGI server and needs to be dispatched to a running application. Note that the flow control window is not modified here. That's deliberate: see Stream.__next__ for a longer discussion of why.
data_frame_received
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def reset_stream(self, event): """ A stream got forcefully reset. This is a tricky thing to deal with because WSGI doesn't really have a good notion for it. Essentially, you have to let the application run until completion, but not actually let it send any data. We do t...
A stream got forcefully reset. This is a tricky thing to deal with because WSGI doesn't really have a good notion for it. Essentially, you have to let the application run until completion, but not actually let it send any data. We do that by discarding any data we currently ha...
reset_stream
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def data_for_stream(self, stream_id, data): """ Thread-safe method called from outside the main asyncio thread in order to send data on behalf of a WSGI application. Places data being written by a stream on an asyncio queue. Returns a threading event that will fire when that dat...
Thread-safe method called from outside the main asyncio thread in order to send data on behalf of a WSGI application. Places data being written by a stream on an asyncio queue. Returns a threading event that will fire when that data is sent.
data_for_stream
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def open_flow_control_window(self, stream_id, increment): """ Opens a flow control window for the given stream by the given amount. Called from a WSGI thread. Does not return an event because there's no need to block on this action, it may take place at any time. """ def ...
Opens a flow control window for the given stream by the given amount. Called from a WSGI thread. Does not return an event because there's no need to block on this action, it may take place at any time.
open_flow_control_window
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def run_in_threadpool(self, wsgi_application, environ): """ This method should be invoked in a threadpool. At the point this method is invoked, the only safe methods to call from the original thread are ``receive_data`` and ``request_complete``: any other method is unsafe. This ...
This method should be invoked in a threadpool. At the point this method is invoked, the only safe methods to call from the original thread are ``receive_data`` and ``request_complete``: any other method is unsafe. This method handles the WSGI logic. It invokes the application callable ...
run_in_threadpool
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def read(self, size=None): """ Called by the WSGI application to read data. This method is the one of two that explicitly pumps the input data queue, which means it deals with the ``_complete`` flag and the ``END_DATA_SENTINEL``. """ # If we've already seen the E...
Called by the WSGI application to read data. This method is the one of two that explicitly pumps the input data queue, which means it deals with the ``_complete`` flag and the ``END_DATA_SENTINEL``.
read
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def readlines(self, hint=None): """ Called by the WSGI application to read several lines of data. """ data = self.read(hint) lines = data.splitlines(keepends=True) return lines
Called by the WSGI application to read several lines of data.
readlines
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def start_response(self, status, response_headers, exc_info=None): """ This is the PEP-3333 mandated start_response callable. All it does is store the headers for later sending, and return our ```write`` callable. """ if self._headers_emitted and exc_info is not None: ...
This is the PEP-3333 mandated start_response callable. All it does is store the headers for later sending, and return our ```write`` callable.
start_response
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def write(self, data): """ Provides some data to write. This function *blocks* until such time as the data is allowed by HTTP/2 flow control. This allows a client to slow or pause the response as needed. This function is not supposed to be used, according to PEP-3333, b...
Provides some data to write. This function *blocks* until such time as the data is allowed by HTTP/2 flow control. This allows a client to slow or pause the response as needed. This function is not supposed to be used, according to PEP-3333, but once we have it it beco...
write
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def _emit_headers(self): """ Sends the response headers. This is only called from the write callable and should only ever be called once. It does some minor processing (converts the status line into a status code because reason phrases are evil) and then passes the heade...
Sends the response headers. This is only called from the write callable and should only ever be called once. It does some minor processing (converts the status line into a status code because reason phrases are evil) and then passes the headers on to the server. This call expli...
_emit_headers
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
def _build_environ_dict(headers, stream): """ Build the WSGI environ dictionary for a given request. To do that, we'll temporarily create a dictionary for the headers. While this isn't actually a valid way to represent headers, we know that the special headers we need can only have one appearance in...
Build the WSGI environ dictionary for a given request. To do that, we'll temporarily create a dictionary for the headers. While this isn't actually a valid way to represent headers, we know that the special headers we need can only have one appearance in the block. This code is arguably somewhat i...
_build_environ_dict
python
python-hyper/h2
examples/asyncio/wsgi-server.py
https://github.com/python-hyper/h2/blob/master/examples/asyncio/wsgi-server.py
MIT
async def create_listening_ssl_socket(address, certfile, keyfile): """ Create and return a listening TLS socket on a given address. """ ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_context.options |= ( ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 | ssl.OP_NO_COMPRESSION )...
Create and return a listening TLS socket on a given address.
create_listening_ssl_socket
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
async def h2_server(address, root, certfile, keyfile): """ Create an HTTP/2 server at the given address. """ sock = await create_listening_ssl_socket(address, certfile, keyfile) print("Now listening on %s:%d" % address) async with sock: while True: client, _ = await sock.acc...
Create an HTTP/2 server at the given address.
h2_server
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
async def run(self): """ Loop over the connection, managing it appropriately. """ self.conn.initiate_connection() await self.sock.sendall(self.conn.data_to_send()) while True: # 65535 is basically arbitrary here: this amounts to "give me # whateve...
Loop over the connection, managing it appropriately.
run
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
async def request_received(self, headers, stream_id): """ Handle a request by attempting to serve a suitable file. """ headers = dict(headers) assert headers[':method'] == 'GET' path = headers[':path'].lstrip('/') full_path = os.path.join(self.root, path) ...
Handle a request by attempting to serve a suitable file.
request_received
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
async def send_file(self, file_path, stream_id): """ Send a file, obeying the rules of HTTP/2 flow control. """ filesize = os.stat(file_path).st_size content_type, content_encoding = mimetypes.guess_type(file_path) response_headers = [ (':status', '200'), ...
Send a file, obeying the rules of HTTP/2 flow control.
send_file
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
async def _send_file_data(self, fileobj, stream_id): """ Send the data portion of a file. Handles flow control rules. """ while True: while self.conn.local_flow_control_window(stream_id) < 1: await self.wait_for_flow_control(stream_id) chunk_size ...
Send the data portion of a file. Handles flow control rules.
_send_file_data
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
async def wait_for_flow_control(self, stream_id): """ Blocks until the flow control window for a given stream is opened. """ evt = Event() self.flow_control_events[stream_id] = evt await evt.wait()
Blocks until the flow control window for a given stream is opened.
wait_for_flow_control
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
async def window_updated(self, event): """ Unblock streams waiting on flow control, if needed. """ stream_id = event.stream_id if stream_id and stream_id in self.flow_control_events: evt = self.flow_control_events.pop(stream_id) await evt.set() el...
Unblock streams waiting on flow control, if needed.
window_updated
python
python-hyper/h2
examples/curio/curio-server.py
https://github.com/python-hyper/h2/blob/master/examples/curio/curio-server.py
MIT
def get_http2_ssl_context(): """ This function creates an SSLContext object that is suitably configured for HTTP/2. If you're working with Python TLS directly, you'll want to do the exact same setup as this function does. """ # Get the basic context from the standard library. ctx = ssl.creat...
This function creates an SSLContext object that is suitably configured for HTTP/2. If you're working with Python TLS directly, you'll want to do the exact same setup as this function does.
get_http2_ssl_context
python
python-hyper/h2
examples/fragments/client_https_setup_fragment.py
https://github.com/python-hyper/h2/blob/master/examples/fragments/client_https_setup_fragment.py
MIT
def send_initial_request(connection, settings): """ For the sake of this upgrade demonstration, we're going to issue a GET request against the root of the site. In principle the best request to issue for an upgrade is actually ``OPTIONS *``, but this is remarkably poorly supported and can break in w...
For the sake of this upgrade demonstration, we're going to issue a GET request against the root of the site. In principle the best request to issue for an upgrade is actually ``OPTIONS *``, but this is remarkably poorly supported and can break in weird ways.
send_initial_request
python
python-hyper/h2
examples/fragments/client_upgrade_fragment.py
https://github.com/python-hyper/h2/blob/master/examples/fragments/client_upgrade_fragment.py
MIT
def get_upgrade_response(connection): """ This function reads from the socket until the HTTP/1.1 end-of-headers sequence (CRLFCRLF) is received. It then checks what the status code of the response is. This is not a substitute for proper HTTP/1.1 parsing, but it's good enough for example purpose...
This function reads from the socket until the HTTP/1.1 end-of-headers sequence (CRLFCRLF) is received. It then checks what the status code of the response is. This is not a substitute for proper HTTP/1.1 parsing, but it's good enough for example purposes.
get_upgrade_response
python
python-hyper/h2
examples/fragments/client_upgrade_fragment.py
https://github.com/python-hyper/h2/blob/master/examples/fragments/client_upgrade_fragment.py
MIT
def establish_tcp_connection(): """ This function establishes a server-side TCP connection. How it works isn't very important to this example. """ bind_socket = socket.socket() bind_socket.bind(('', 443)) bind_socket.listen(5) return bind_socket.accept()[0]
This function establishes a server-side TCP connection. How it works isn't very important to this example.
establish_tcp_connection
python
python-hyper/h2
examples/fragments/server_https_setup_fragment.py
https://github.com/python-hyper/h2/blob/master/examples/fragments/server_https_setup_fragment.py
MIT
def receive_initial_request(connection): """ We're going to receive a request. For the sake of this example, we're going to assume that the first request has no body. If it doesn't have the Upgrade: h2c header field and the HTTP2-Settings header field, we'll throw errors. In production code, yo...
We're going to receive a request. For the sake of this example, we're going to assume that the first request has no body. If it doesn't have the Upgrade: h2c header field and the HTTP2-Settings header field, we'll throw errors. In production code, you should use a proper HTTP/1.1 parser and actual...
receive_initial_request
python
python-hyper/h2
examples/fragments/server_upgrade_fragment.py
https://github.com/python-hyper/h2/blob/master/examples/fragments/server_upgrade_fragment.py
MIT
def send_upgrade_response(connection): """ This function writes the 101 Switching Protocols response. """ response = ( b"HTTP/1.1 101 Switching Protocols\r\n" b"Upgrade: h2c\r\n" b"\r\n" ) connection.sendall(response)
This function writes the 101 Switching Protocols response.
send_upgrade_response
python
python-hyper/h2
examples/fragments/server_upgrade_fragment.py
https://github.com/python-hyper/h2/blob/master/examples/fragments/server_upgrade_fragment.py
MIT
def dataReceived(self, data): """ Called by Twisted when data is received on the connection. We need to check a few things here. Firstly, we want to validate that we actually negotiated HTTP/2: if we didn't, we shouldn't proceed! Then, we want to pass the data to the protocol s...
Called by Twisted when data is received on the connection. We need to check a few things here. Firstly, we want to validate that we actually negotiated HTTP/2: if we didn't, we shouldn't proceed! Then, we want to pass the data to the protocol stack and check what events occurr...
dataReceived
python
python-hyper/h2
examples/twisted/post_request.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/post_request.py
MIT
def handleResponse(self, response_headers): """ Handle the response by printing the response headers. """ for name, value in response_headers: print("%s: %s" % (name.decode('utf-8'), value.decode('utf-8'))) print("")
Handle the response by printing the response headers.
handleResponse
python
python-hyper/h2
examples/twisted/post_request.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/post_request.py
MIT
def endStream(self): """ We call this when the stream is cleanly ended by the remote peer. That means that the response is complete. Because this code only makes a single HTTP/2 request, once we receive the complete response we can safely tear the connection down and stop ...
We call this when the stream is cleanly ended by the remote peer. That means that the response is complete. Because this code only makes a single HTTP/2 request, once we receive the complete response we can safely tear the connection down and stop the reactor. We do that as cle...
endStream
python
python-hyper/h2
examples/twisted/post_request.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/post_request.py
MIT
def windowUpdated(self, event): """ We call this when the flow control window for the connection or the stream has been widened. If there's a flow control deferred present (that is, if we're blocked behind the flow control), we fire it. Otherwise, we do nothing. """ ...
We call this when the flow control window for the connection or the stream has been widened. If there's a flow control deferred present (that is, if we're blocked behind the flow control), we fire it. Otherwise, we do nothing.
windowUpdated
python
python-hyper/h2
examples/twisted/post_request.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/post_request.py
MIT
def connectionLost(self, reason=None): """ Called by Twisted when the connection is gone. Regardless of whether it was clean or not, we want to stop the reactor. """ if self.fileobj is not None: self.fileobj.close() if reactor.running: reactor.sto...
Called by Twisted when the connection is gone. Regardless of whether it was clean or not, we want to stop the reactor.
connectionLost
python
python-hyper/h2
examples/twisted/post_request.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/post_request.py
MIT
def sendRequest(self): """ Send the POST request. A POST request is made up of one headers frame, and then 0+ data frames. This method begins by sending the headers, and then starts a series of calls to send data. """ # First, we need to work out how large the fi...
Send the POST request. A POST request is made up of one headers frame, and then 0+ data frames. This method begins by sending the headers, and then starts a series of calls to send data.
sendRequest
python
python-hyper/h2
examples/twisted/post_request.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/post_request.py
MIT
def sendFileData(self): """ Send some file data on the connection. """ # Firstly, check what the flow control window is for stream 1. window_size = self.conn.local_flow_control_window(stream_id=1) # Next, check what the maximum frame size is. max_frame_size = sel...
Send some file data on the connection.
sendFileData
python
python-hyper/h2
examples/twisted/post_request.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/post_request.py
MIT
def windowUpdated(self, event): """ Handle a WindowUpdated event by firing any waiting data sending callbacks. """ stream_id = event.stream_id if stream_id and stream_id in self._flow_control_deferreds: d = self._flow_control_deferreds.pop(stream_id) ...
Handle a WindowUpdated event by firing any waiting data sending callbacks.
windowUpdated
python
python-hyper/h2
examples/twisted/twisted-server.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/twisted-server.py
MIT
def _send_file(self, file, stream_id): """ This callback sends more data for a given file on the stream. """ keep_reading = True while keep_reading: while not self.conn.remote_flow_control_window(stream_id): yield self.wait_for_flow_control(stream_id) ...
This callback sends more data for a given file on the stream.
_send_file
python
python-hyper/h2
examples/twisted/twisted-server.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/twisted-server.py
MIT
def wait_for_flow_control(self, stream_id): """ Returns a Deferred that fires when the flow control window is opened. """ d = Deferred() self._flow_control_deferreds[stream_id] = d return d
Returns a Deferred that fires when the flow control window is opened.
wait_for_flow_control
python
python-hyper/h2
examples/twisted/twisted-server.py
https://github.com/python-hyper/h2/blob/master/examples/twisted/twisted-server.py
MIT
def debug(self, *vargs, **kwargs) -> None: # type: ignore """ No-op logging. Only level needed for now. """
No-op logging. Only level needed for now.
debug
python
python-hyper/h2
src/h2/config.py
https://github.com/python-hyper/h2/blob/master/src/h2/config.py
MIT
def header_encoding(self, value: bool | str | None) -> None: """ Enforces constraints on the value of header encoding. """ if not isinstance(value, (bool, str, type(None))): msg = "header_encoding must be bool, string, or None" raise ValueError(msg) # noqa: TRY00...
Enforces constraints on the value of header encoding.
header_encoding
python
python-hyper/h2
src/h2/config.py
https://github.com/python-hyper/h2/blob/master/src/h2/config.py
MIT
def process_input(self, input_: ConnectionInputs) -> list[Event]: """ Process a specific input in the state machine. """ if not isinstance(input_, ConnectionInputs): msg = "Input must be an instance of ConnectionInputs" raise ValueError(msg) # noqa: TRY004 ...
Process a specific input in the state machine.
process_input
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _open_streams(self, remainder: int) -> int: """ A common method of counting number of open streams. Returns the number of streams that are open *and* that have (stream ID % 2) == remainder. While it iterates, also deletes any closed streams. """ count = 0 to_d...
A common method of counting number of open streams. Returns the number of streams that are open *and* that have (stream ID % 2) == remainder. While it iterates, also deletes any closed streams.
_open_streams
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _begin_new_stream(self, stream_id: int, allowed_ids: AllowedStreamIDs) -> H2Stream: """ Initiate a new stream. .. versionchanged:: 2.0.0 Removed this function from the public API. :param stream_id: The ID of the stream to open. :param allowed_ids: What kind of st...
Initiate a new stream. .. versionchanged:: 2.0.0 Removed this function from the public API. :param stream_id: The ID of the stream to open. :param allowed_ids: What kind of stream ID is allowed.
_begin_new_stream
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def initiate_connection(self) -> None: """ Provides any data that needs to be sent at the start of the connection. Must be called for both clients and servers. """ self.config.logger.debug("Initializing connection") self.state_machine.process_input(ConnectionInputs.SEND_S...
Provides any data that needs to be sent at the start of the connection. Must be called for both clients and servers.
initiate_connection
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def initiate_upgrade_connection(self, settings_header: bytes | None = None) -> bytes | None: """ Call to initialise the connection object for use with an upgraded HTTP/2 connection (i.e. a connection negotiated using the ``Upgrade: h2c`` HTTP header). This method differs from :m...
Call to initialise the connection object for use with an upgraded HTTP/2 connection (i.e. a connection negotiated using the ``Upgrade: h2c`` HTTP header). This method differs from :meth:`initiate_connection <h2.connection.H2Connection.initiate_connection>` in several ways. ...
initiate_upgrade_connection
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _get_or_create_stream(self, stream_id: int, allowed_ids: AllowedStreamIDs) -> H2Stream: """ Gets a stream by its stream ID. Will create one if one does not already exist. Use allowed_ids to circumvent the usual stream ID rules for clients and servers. .. versionchanged:: 2.0...
Gets a stream by its stream ID. Will create one if one does not already exist. Use allowed_ids to circumvent the usual stream ID rules for clients and servers. .. versionchanged:: 2.0.0 Removed this function from the public API.
_get_or_create_stream
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _get_stream_by_id(self, stream_id: int | None) -> H2Stream: """ Gets a stream by its stream ID. Raises NoSuchStreamError if the stream ID does not correspond to a known stream and is higher than the current maximum: raises if it is lower than the current maximum. .. versionc...
Gets a stream by its stream ID. Raises NoSuchStreamError if the stream ID does not correspond to a known stream and is higher than the current maximum: raises if it is lower than the current maximum. .. versionchanged:: 2.0.0 Removed this function from the public API. ...
_get_stream_by_id
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def get_next_available_stream_id(self) -> int: """ Returns an integer suitable for use as the stream ID for the next stream created by this endpoint. For server endpoints, this stream ID will be even. For client endpoints, this stream ID will be odd. If no stream IDs are availabl...
Returns an integer suitable for use as the stream ID for the next stream created by this endpoint. For server endpoints, this stream ID will be even. For client endpoints, this stream ID will be odd. If no stream IDs are available, raises :class:`NoAvailableStreamIDError <h2.exc...
get_next_available_stream_id
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def send_headers(self, stream_id: int, headers: Iterable[HeaderWeaklyTyped], end_stream: bool = False, priority_weight: int | None = None, priority_depends_on: int | None = None, priority_exclus...
Send headers on a given stream. This function can be used to send request or response headers: the kind that are sent depends on whether this connection has been opened as a client or server connection, and whether the stream was opened by the remote peer or not. If th...
send_headers
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def send_data(self, stream_id: int, data: bytes | memoryview, end_stream: bool = False, pad_length: Any = None) -> None: """ Send data on a given stream. This method does no breaking up of data: if the data is larger than t...
Send data on a given stream. This method does no breaking up of data: if the data is larger than the value returned by :meth:`local_flow_control_window <h2.connection.H2Connection.local_flow_control_window>` for this stream then a :class:`FlowControlError <h2.exceptions.FlowCon...
send_data
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def end_stream(self, stream_id: int) -> None: """ Cleanly end a given stream. This method ends a stream by sending an empty DATA frame on that stream with the ``END_STREAM`` flag set. :param stream_id: The ID of the stream to end. :type stream_id: ``int`` :retur...
Cleanly end a given stream. This method ends a stream by sending an empty DATA frame on that stream with the ``END_STREAM`` flag set. :param stream_id: The ID of the stream to end. :type stream_id: ``int`` :returns: Nothing
end_stream
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def increment_flow_control_window(self, increment: int, stream_id: int | None = None) -> None: """ Increment a flow control window, optionally for a single stream. Allows the remote peer to send more data. .. versionchanged:: 2.0.0 Rejects attempts to increment the flow contr...
Increment a flow control window, optionally for a single stream. Allows the remote peer to send more data. .. versionchanged:: 2.0.0 Rejects attempts to increment the flow control window by out of range values with a ``ValueError``. :param increment: The amount t...
increment_flow_control_window
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def ping(self, opaque_data: bytes | str) -> None: """ Send a PING frame. :param opaque_data: A bytestring of length 8 that will be sent in the PING frame. :returns: Nothing """ self.config.logger.debug("Send Ping frame") if not isinst...
Send a PING frame. :param opaque_data: A bytestring of length 8 that will be sent in the PING frame. :returns: Nothing
ping
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def reset_stream(self, stream_id: int, error_code: ErrorCodes | int = 0) -> None: """ Reset a stream. This method forcibly closes a stream by sending a RST_STREAM frame for a given stream. This is not a graceful closure. To gracefully end a stream, try the :meth:`end_stream ...
Reset a stream. This method forcibly closes a stream by sending a RST_STREAM frame for a given stream. This is not a graceful closure. To gracefully end a stream, try the :meth:`end_stream <h2.connection.H2Connection.end_stream>` method. :param stream_id: The ID of the...
reset_stream
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def advertise_alternative_service(self, field_value: bytes | str, origin: bytes | None = None, stream_id: int | None = None) -> None: """ Notify a client about an available Alternative Servi...
Notify a client about an available Alternative Service. An Alternative Service is defined in `RFC 7838 <https://tools.ietf.org/html/rfc7838>`_. An Alternative Service notification informs a client that a given origin is also available elsewhere. Alternative Services ca...
advertise_alternative_service
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def prioritize(self, stream_id: int, weight: int | None = None, depends_on: int | None = None, exclusive: bool | None = None) -> None: """ Notify a server about the priority of a stream. Stream priorities are a form of ...
Notify a server about the priority of a stream. Stream priorities are a form of guidance to a remote server: they inform the server about how important a given response is, so that the server may allocate its resources (e.g. bandwidth, CPU time, etc.) accordingly. This exists t...
prioritize
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def local_flow_control_window(self, stream_id: int) -> int: """ Returns the maximum amount of data that can be sent on stream ``stream_id``. This value will never be larger than the total data that can be sent on the connection: even if the given stream allows more data, the ...
Returns the maximum amount of data that can be sent on stream ``stream_id``. This value will never be larger than the total data that can be sent on the connection: even if the given stream allows more data, the connection window provides a logical maximum to the amount of data...
local_flow_control_window
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def remote_flow_control_window(self, stream_id: int) -> int: """ Returns the maximum amount of data the remote peer can send on stream ``stream_id``. This value will never be larger than the total data that can be sent on the connection: even if the given stream allows more data...
Returns the maximum amount of data the remote peer can send on stream ``stream_id``. This value will never be larger than the total data that can be sent on the connection: even if the given stream allows more data, the connection window provides a logical maximum to the amount...
remote_flow_control_window
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def acknowledge_received_data(self, acknowledged_size: int, stream_id: int) -> None: """ Inform the :class:`H2Connection <h2.connection.H2Connection>` that a certain number of flow-controlled bytes have been processed, and that the space should be handed back to the remote peer at an opp...
Inform the :class:`H2Connection <h2.connection.H2Connection>` that a certain number of flow-controlled bytes have been processed, and that the space should be handed back to the remote peer at an opportune time. .. versionadded:: 2.5.0 :param acknowledged_size: The tot...
acknowledge_received_data
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def data_to_send(self, amount: int | None = None) -> bytes: """ Returns some data for sending out of the internal data buffer. This method is analogous to ``read`` on a file-like object, but it doesn't block. Instead, it returns as much data as the user asks for, or less if that...
Returns some data for sending out of the internal data buffer. This method is analogous to ``read`` on a file-like object, but it doesn't block. Instead, it returns as much data as the user asks for, or less if that much data is not available. It does not perform any I/O, and s...
data_to_send
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _acknowledge_settings(self) -> list[Frame]: """ Acknowledge settings that have been received. .. versionchanged:: 2.0.0 Removed from public API, removed useless ``event`` parameter, made automatic. :returns: Nothing """ self.state_machine.proce...
Acknowledge settings that have been received. .. versionchanged:: 2.0.0 Removed from public API, removed useless ``event`` parameter, made automatic. :returns: Nothing
_acknowledge_settings
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _flow_control_change_from_settings(self, old_value: int | None, new_value: int) -> None: """ Update flow control windows in response to a change in the value of SETTINGS_INITIAL_WINDOW_SIZE. When this setting is changed, it automatically updates all flow control windows by t...
Update flow control windows in response to a change in the value of SETTINGS_INITIAL_WINDOW_SIZE. When this setting is changed, it automatically updates all flow control windows by the delta in the settings values. Note that it does not increment the *connection* flow control w...
_flow_control_change_from_settings
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _inbound_flow_control_change_from_settings(self, old_value: int | None, new_value: int) -> None: """ Update remote flow control windows in response to a change in the value of SETTINGS_INITIAL_WINDOW_SIZE. When this setting is changed, it automatically updates all remote flow ...
Update remote flow control windows in response to a change in the value of SETTINGS_INITIAL_WINDOW_SIZE. When this setting is changed, it automatically updates all remote flow control windows by the delta in the settings values.
_inbound_flow_control_change_from_settings
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def receive_data(self, data: bytes) -> list[Event]: """ Pass some received HTTP/2 data to the connection for handling. :param data: The data received from the remote peer on the network. :type data: ``bytes`` :returns: A list of events that the remote peer triggered by sending ...
Pass some received HTTP/2 data to the connection for handling. :param data: The data received from the remote peer on the network. :type data: ``bytes`` :returns: A list of events that the remote peer triggered by sending this data.
receive_data
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_frame(self, frame: Frame) -> list[Event]: """ Handle a frame received on the connection. .. versionchanged:: 2.0.0 Removed from the public API. """ events: list[Event] self.config.logger.trace("Received frame: %s", repr(frame)) try: ...
Handle a frame received on the connection. .. versionchanged:: 2.0.0 Removed from the public API.
_receive_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _terminate_connection(self, error_code: ErrorCodes) -> None: """ Terminate the connection early. Used in error handling blocks to send GOAWAY frames. """ f = GoAwayFrame(0) f.last_stream_id = self.highest_inbound_stream_id f.error_code = error_code sel...
Terminate the connection early. Used in error handling blocks to send GOAWAY frames.
_terminate_connection
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_headers_frame(self, frame: HeadersFrame) -> tuple[list[Frame], list[Event]]: """ Receive a headers frame on the connection. """ # If necessary, check we can open the stream. Also validate that the # stream ID is valid. if frame.stream_id not in self.streams: ...
Receive a headers frame on the connection.
_receive_headers_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_data_frame(self, frame: DataFrame) -> tuple[list[Frame], list[Event]]: """ Receive a data frame on the connection. """ flow_controlled_length = frame.flow_controlled_length events = self.state_machine.process_input( ConnectionInputs.RECV_DATA, ) ...
Receive a data frame on the connection.
_receive_data_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_settings_frame(self, frame: SettingsFrame) -> tuple[list[Frame], list[Event]]: """ Receive a SETTINGS frame on the connection. """ events = self.state_machine.process_input( ConnectionInputs.RECV_SETTINGS, ) # This is an ack of the local settings...
Receive a SETTINGS frame on the connection.
_receive_settings_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_ping_frame(self, frame: PingFrame) -> tuple[list[Frame], list[Event]]: """ Receive a PING frame on the connection. """ events = self.state_machine.process_input( ConnectionInputs.RECV_PING, ) frames: list[Frame] = [] evt: PingReceived | P...
Receive a PING frame on the connection.
_receive_ping_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_priority_frame(self, frame: HeadersFrame | PriorityFrame) -> tuple[list[Frame], list[Event]]: """ Receive a PRIORITY frame on the connection. """ events = self.state_machine.process_input( ConnectionInputs.RECV_PRIORITY, ) event = PriorityUpdated...
Receive a PRIORITY frame on the connection.
_receive_priority_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_goaway_frame(self, frame: GoAwayFrame) -> tuple[list[Frame], list[Event]]: """ Receive a GOAWAY frame on the connection. """ events = self.state_machine.process_input( ConnectionInputs.RECV_GOAWAY, ) # Clear the outbound data buffer: we cannot se...
Receive a GOAWAY frame on the connection.
_receive_goaway_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_naked_continuation(self, frame: ContinuationFrame) -> None: """ A naked CONTINUATION frame has been received. This is always an error, but the type of error it is depends on the state of the stream and must transition the state of the stream, so we need to pass it to the ...
A naked CONTINUATION frame has been received. This is always an error, but the type of error it is depends on the state of the stream and must transition the state of the stream, so we need to pass it to the appropriate stream.
_receive_naked_continuation
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _receive_alt_svc_frame(self, frame: AltSvcFrame) -> tuple[list[Frame], list[Event]]: """ An ALTSVC frame has been received. This frame, specified in RFC 7838, is used to advertise alternative places where the same service can be reached. This frame can optionally be received...
An ALTSVC frame has been received. This frame, specified in RFC 7838, is used to advertise alternative places where the same service can be reached. This frame can optionally be received either on a stream or on stream 0, and its semantics are different in each case.
_receive_alt_svc_frame
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _local_settings_acked(self) -> dict[SettingCodes | int, ChangedSetting]: """ Handle the local settings being ACKed, update internal state. """ changes = self.local_settings.acknowledge() if SettingCodes.INITIAL_WINDOW_SIZE in changes: setting = changes[SettingCod...
Handle the local settings being ACKed, update internal state.
_local_settings_acked
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _stream_closed_by(self, stream_id: int) -> StreamClosedBy | None: """ Returns how the stream was closed. The return value will be either a member of ``h2.stream.StreamClosedBy`` or ``None``. If ``None``, the stream was closed implicitly by the peer opening a stream with a hi...
Returns how the stream was closed. The return value will be either a member of ``h2.stream.StreamClosedBy`` or ``None``. If ``None``, the stream was closed implicitly by the peer opening a stream with a higher stream ID before opening this one.
_stream_closed_by
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _stream_is_closed_by_reset(self, stream_id: int) -> bool: """ Returns ``True`` if the stream was closed by sending or receiving a RST_STREAM frame. Returns ``False`` otherwise. """ return self._stream_closed_by(stream_id) in ( StreamClosedBy.RECV_RST_STREAM, Strea...
Returns ``True`` if the stream was closed by sending or receiving a RST_STREAM frame. Returns ``False`` otherwise.
_stream_is_closed_by_reset
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _stream_is_closed_by_end(self, stream_id: int) -> bool: """ Returns ``True`` if the stream was closed by sending or receiving an END_STREAM flag in a HEADERS or DATA frame. Returns ``False`` otherwise. """ return self._stream_closed_by(stream_id) in ( Stre...
Returns ``True`` if the stream was closed by sending or receiving an END_STREAM flag in a HEADERS or DATA frame. Returns ``False`` otherwise.
_stream_is_closed_by_end
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _add_frame_priority(frame: PriorityFrame | HeadersFrame, weight: int | None = None, depends_on: int | None = None, exclusive: bool | None = None) -> PriorityFrame | HeadersFrame: """ Adds priority data to a given frame. Does not change ...
Adds priority data to a given frame. Does not change any flags set on that frame: if the caller is adding priority information to a HEADERS frame they must set that themselves. This method also deliberately sets defaults for anything missing. This method validates the input values.
_add_frame_priority
python
python-hyper/h2
src/h2/connection.py
https://github.com/python-hyper/h2/blob/master/src/h2/connection.py
MIT
def _error_code_from_int(code: int) -> ErrorCodes | int: """ Given an integer error code, returns either one of :class:`ErrorCodes <h2.errors.ErrorCodes>` or, if not present in the known set of codes, returns the integer directly. """ try: return ErrorCodes(code) except ValueError: ...
Given an integer error code, returns either one of :class:`ErrorCodes <h2.errors.ErrorCodes>` or, if not present in the known set of codes, returns the integer directly.
_error_code_from_int
python
python-hyper/h2
src/h2/errors.py
https://github.com/python-hyper/h2/blob/master/src/h2/errors.py
MIT
def from_settings(cls, old_settings: Settings | dict[int, int], new_settings: dict[int, int]) -> RemoteSettingsChanged: """ Build a RemoteSettingsChanged event from a set of changed settings. :param old_settings: A complete collection of old settings,...
Build a RemoteSettingsChanged event from a set of changed settings. :param old_settings: A complete collection of old settings, in the form of a dictionary of ``{setting: value}``. :param new_settings: All the changed settings and their new values, in ...
from_settings
python
python-hyper/h2
src/h2/events.py
https://github.com/python-hyper/h2/blob/master/src/h2/events.py
MIT
def _bytes_representation(data: bytes | None) -> str | None: """ Converts a bytestring into something that is safe to print on all Python platforms. This function is relatively expensive, so it should not be called on the mainline of the code. It's safe to use in things like object repr methods ...
Converts a bytestring into something that is safe to print on all Python platforms. This function is relatively expensive, so it should not be called on the mainline of the code. It's safe to use in things like object repr methods though.
_bytes_representation
python
python-hyper/h2
src/h2/events.py
https://github.com/python-hyper/h2/blob/master/src/h2/events.py
MIT
def add_data(self, data: bytes) -> None: """ Add more data to the frame buffer. :param data: A bytestring containing the byte buffer. """ if self._preamble_len: data_len = len(data) of_which_preamble = min(self._preamble_len, data_len) if sel...
Add more data to the frame buffer. :param data: A bytestring containing the byte buffer.
add_data
python
python-hyper/h2
src/h2/frame_buffer.py
https://github.com/python-hyper/h2/blob/master/src/h2/frame_buffer.py
MIT
def _validate_frame_length(self, length: int) -> None: """ Confirm that the frame is an appropriate length. """ if length > self.max_frame_size: msg = f"Received overlong frame: length {length}, max {self.max_frame_size}" raise FrameTooLargeError(msg)
Confirm that the frame is an appropriate length.
_validate_frame_length
python
python-hyper/h2
src/h2/frame_buffer.py
https://github.com/python-hyper/h2/blob/master/src/h2/frame_buffer.py
MIT
def _update_header_buffer(self, f: Frame | None) -> Frame | None: """ Updates the internal header buffer. Returns a frame that should replace the current one. May throw exceptions if this frame is invalid. """ # Check if we're in the middle of a headers block. If we are, this ...
Updates the internal header buffer. Returns a frame that should replace the current one. May throw exceptions if this frame is invalid.
_update_header_buffer
python
python-hyper/h2
src/h2/frame_buffer.py
https://github.com/python-hyper/h2/blob/master/src/h2/frame_buffer.py
MIT
def _setting_code_from_int(code: int) -> SettingCodes | int: """ Given an integer setting code, returns either one of :class:`SettingCodes <h2.settings.SettingCodes>` or, if not present in the known set of codes, returns the integer directly. """ try: return SettingCodes(code) except...
Given an integer setting code, returns either one of :class:`SettingCodes <h2.settings.SettingCodes>` or, if not present in the known set of codes, returns the integer directly.
_setting_code_from_int
python
python-hyper/h2
src/h2/settings.py
https://github.com/python-hyper/h2/blob/master/src/h2/settings.py
MIT
def acknowledge(self) -> dict[SettingCodes | int, ChangedSetting]: """ The settings have been acknowledged, either by the user (remote settings) or by the remote peer (local settings). :returns: A dict of {setting: ChangedSetting} that were applied. """ changed_settings:...
The settings have been acknowledged, either by the user (remote settings) or by the remote peer (local settings). :returns: A dict of {setting: ChangedSetting} that were applied.
acknowledge
python
python-hyper/h2
src/h2/settings.py
https://github.com/python-hyper/h2/blob/master/src/h2/settings.py
MIT
def _validate_setting(setting: SettingCodes | int, value: int) -> ErrorCodes: """ Confirms that a specific setting has a well-formed value. If the setting is invalid, returns an error code. Otherwise, returns 0 (NO_ERROR). """ if setting == SettingCodes.ENABLE_PUSH: if value not in (0, 1): ...
Confirms that a specific setting has a well-formed value. If the setting is invalid, returns an error code. Otherwise, returns 0 (NO_ERROR).
_validate_setting
python
python-hyper/h2
src/h2/settings.py
https://github.com/python-hyper/h2/blob/master/src/h2/settings.py
MIT
def response_sent(self, previous_state: StreamState) -> list[Event]: """ Fires when something that should be a response is sent. This 'response' may actually be trailers. """ if not self.headers_sent: if self.client is True or self.client is None: msg ...
Fires when something that should be a response is sent. This 'response' may actually be trailers.
response_sent
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def response_received(self, previous_state: StreamState) -> list[Event]: """ Fires when a response is received. Also disambiguates between responses and trailers. """ event: ResponseReceived | TrailersReceived if not self.headers_received: assert self.client i...
Fires when a response is received. Also disambiguates between responses and trailers.
response_received
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def stream_ended(self, previous_state: StreamState) -> list[Event]: """ Fires when a stream is cleanly ended. """ self.stream_closed_by = StreamClosedBy.RECV_END_STREAM event = StreamEnded(stream_id=self.stream_id) return [event]
Fires when a stream is cleanly ended.
stream_ended
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def send_new_pushed_stream(self, previous_state: StreamState) -> list[Event]: """ Fires on the newly pushed stream, when pushed by the local peer. No event here, but definitionally this peer must be a server. """ assert self.client is None self.client = False sel...
Fires on the newly pushed stream, when pushed by the local peer. No event here, but definitionally this peer must be a server.
send_new_pushed_stream
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def recv_new_pushed_stream(self, previous_state: StreamState) -> list[Event]: """ Fires on the newly pushed stream, when pushed by the remote peer. No event here, but definitionally this peer must be a client. """ assert self.client is None self.client = True sel...
Fires on the newly pushed stream, when pushed by the remote peer. No event here, but definitionally this peer must be a client.
recv_new_pushed_stream
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def send_push_promise(self, previous_state: StreamState) -> list[Event]: """ Fires on the already-existing stream when a PUSH_PROMISE frame is sent. We may only send PUSH_PROMISE frames if we're a server. """ if self.client is True: msg = "Cannot push streams from cli...
Fires on the already-existing stream when a PUSH_PROMISE frame is sent. We may only send PUSH_PROMISE frames if we're a server.
send_push_promise
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def recv_push_promise(self, previous_state: StreamState) -> list[Event]: """ Fires on the already-existing stream when a PUSH_PROMISE frame is received. We may only receive PUSH_PROMISE frames if we're a client. Fires a PushedStreamReceived event. """ if not self.client:...
Fires on the already-existing stream when a PUSH_PROMISE frame is received. We may only receive PUSH_PROMISE frames if we're a client. Fires a PushedStreamReceived event.
recv_push_promise
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def recv_push_on_closed_stream(self, previous_state: StreamState) -> list[Event]: """ Called when a PUSH_PROMISE frame is received on a full stop stream. If the stream was closed by us sending a RST_STREAM frame, then we presume that the PUSH_PROMISE was in flight when we reset ...
Called when a PUSH_PROMISE frame is received on a full stop stream. If the stream was closed by us sending a RST_STREAM frame, then we presume that the PUSH_PROMISE was in flight when we reset the parent stream. Rathen than accept the new stream, we just reset it. Other...
recv_push_on_closed_stream
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def send_informational_response(self, previous_state: StreamState) -> list[Event]: """ Called when an informational header block is sent (that is, a block where the :status header has a 1XX value). Only enforces that these are sent *before* final headers are sent. """ if...
Called when an informational header block is sent (that is, a block where the :status header has a 1XX value). Only enforces that these are sent *before* final headers are sent.
send_informational_response
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def recv_informational_response(self, previous_state: StreamState) -> list[Event]: """ Called when an informational header block is received (that is, a block where the :status header has a 1XX value). """ if self.headers_received: msg = "Informational response after ...
Called when an informational header block is received (that is, a block where the :status header has a 1XX value).
recv_informational_response
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT
def send_alt_svc(self, previous_state: StreamState) -> list[Event]: """ Called when sending an ALTSVC frame on this stream. For consistency with the restrictions we apply on receiving ALTSVC frames in ``recv_alt_svc``, we want to restrict when users can send ALTSVC frames to the...
Called when sending an ALTSVC frame on this stream. For consistency with the restrictions we apply on receiving ALTSVC frames in ``recv_alt_svc``, we want to restrict when users can send ALTSVC frames to the situations when we ourselves would accept them. That means: when we a...
send_alt_svc
python
python-hyper/h2
src/h2/stream.py
https://github.com/python-hyper/h2/blob/master/src/h2/stream.py
MIT