twisted.web._http2View Source (View In Hierarchy)
A class representing a single HTTP/2 stream.
This class works hand-in-hand with
It acts to provide an implementation of
that work for a single HTTP/2 connection, while tightly cleaving to the
interface provided by those interfaces. It does this by having a tight
which allows associating many of the functions of
to objects on a stream-specific level.
|Instance Variable||streamID||The numerical stream ID that this object corresponds to. (type:
|Instance Variable||producing||Whether this stream is currently allowed to produce data to its consumer. (type:
|Instance Variable||command||The HTTP verb used on the request. (type:
|Instance Variable||path||The HTTP path used on the request. (type:
|Instance Variable||producer||The object producing the response, if any. (type:
|Method||__init__||Initialize this HTTP/2 stream.|
|Method||connectionLost||Called by the
|Method||windowUpdated||Called by the
|Method||flowControlBlocked||Called by the
|Method||writeHeaders||Called by the consumer to write headers to the stream.|
|Method||requestDone||Called by a consumer to clean up whatever permanent state is in use.|
|Method||write||Write a single chunk of data into a data frame.|
|Method||writeSequence||Write a sequence of chunks of data into data frames.|
|Method||loseConnection||Close the connection after writing all pending data.|
|Method||abortConnection||Forcefully abort the connection by sending a RstStream frame.|
|Method||getPeer||Get information about the peer.|
|Method||getHost||Similar to getPeer, but for this side of the connection.|
|Method||registerProducer||Register to receive data from a producer.|
|Instance Variable||_producerProducing||Whether the producer stored in producer is currently producing data. (type:
|Instance Variable||_inboundDataBuffer||Any data that has been received from the network but has not yet been
received by the consumer. (type: A
|Instance Variable||_conn||A reference to the connection this stream belongs to. (type:
|Instance Variable||_request||A request object that this stream corresponds to. (type:
|Instance Variable||_buffer||A buffer containing data produced by the producer that could not be sent on
the network at this time. (type:
|Method||_convertHeaders||This method converts the HTTP/2 header set into something that looks like HTTP/1.1. In particular, it strips the 'special' headers and adds a Host: header.|
|Method||_send100Continue||Sends a 100 Continue response, used to signal to clients that further processing will be performed.|
|Method||_respondToBadRequestAndDisconnect||This is a quick and dirty way of responding to bad requests.|
Initialize this HTTP/2 stream.
|Parameters||streamID||The numerical stream ID that this object corresponds to. (type: |
|connection||The HTTP/2 connection this stream belongs to. (type: |
|headers||The HTTP/2 request headers. (type: A |
|requestFactory||A function that builds appropriate request request objects. (type: A callable that returns a |
Called when the connection has received a chunk of data from the underlying transport. If the stream has been registered with a consumer, and is currently able to push data, immediately passes it through. Otherwise, buffers the chunk until we can start producing.
|Parameters||data||The chunk of data that was received. (type: |
|flowControlledLength||The total flow controlled length of this chunk, which is used when we want
to re-open the window. May be different to |
Called by the
when this stream's flow control window has been opened.
Called by the
when this stream's flow control window has been exhausted.
Called by a consumer to clean up whatever permanent state is in use.
|Parameters||request||The request calling the method. (type: |
Sends a 100 Continue response, used to signal to clients that further processing will be performed.
This is a quick and dirty way of responding to bad requests.
As described by HTTP standard we should be patient and accept the whole request from the client before sending a polite bad request response, even in the case when clients send tons of data.
Unlike in the HTTP/1.1 case, this does not actually disconnect the underlying transport: there's no need. This instead just sends a 400 response and terminates the stream.
Close the connection after writing all pending data.
Forcefully abort the connection by sending a RstStream frame.
Get information about the peer.
Similar to getPeer, but for this side of the connection.
Register to receive data from a producer.
This sets self to be a consumer for a producer. When this object runs out of data (as when a send(2) call on a socket succeeds in moving the last data from a userspace buffer into a kernelspace buffer), it will ask the producer to resumeProducing().
resumeProducing will be called once each time data
pauseProducing will be called whenever the write
buffer fills up and
resumeProducing will only be called when
|Parameters||producer||The producer to register. (type: |
|Raises||RuntimeError||If a producer is already registered.|