class documentation

class Stream:

View In Hierarchy

Represents a single HTTP/2 Stream.

Stream is a bidirectional flow of bytes within an established connection, which may carry one or more messages. Handles the transfer of HTTP Headers and Data frames.

Role of this class is to 1. Combine all the data frames

Method __init__ No summary
Method __str__ Undocumented
Method ​_fire​_response​_deferred Builds response from the self._response dict and fires the response deferred callback with the generated response instance
Method ​_get​_request​_headers Undocumented
Method check​_request​_url Undocumented
Method close Based on the reason sent we will handle each case.
Method get​_response Simply return a Deferred which fires when response from the asynchronous request is available
Method initiate​_request Undocumented
Method receive​_data Undocumented
Method receive​_headers Undocumented
Method receive​_window​_update Flow control window size was changed. Send data that earlier could not be sent as we were blocked behind the flow control.
Method reset​_stream Close this stream by sending a RST_FRAME to the remote peer
Method send​_data Called immediately after the headers are sent. Here we send all the data as part of the request.
Instance Variable ​_deferred​_response Undocumented
Instance Variable ​_download​_maxsize Undocumented
Instance Variable ​_download​_warnsize Undocumented
Instance Variable ​_protocol Undocumented
Instance Variable ​_request Undocumented
Instance Variable ​_response Undocumented
Instance Variable metadata Undocumented
Instance Variable stream​_id Undocumented
Property ​_log​_warnsize Checks if we have received data which exceeds the download warnsize and whether we have not already logged about it.
def __init__(self, stream_id, request, protocol, download_maxsize=0, download_warnsize=0):
Arguments:
stream_id -- Unique identifier for the stream within a single HTTP/2 connection request -- The HTTP request associated to the stream protocol -- Parent H2ClientProtocol instance
Parameters
stream​_id:intUndocumented
request:RequestUndocumented
protocol:H2ClientProtocolUndocumented
download​_maxsize:intUndocumented
download​_warnsize:intUndocumented
def __str__(self):

Undocumented

Returns
strUndocumented
def _fire_response_deferred(self):
Builds response from the self._response dict and fires the response deferred callback with the generated response instance
def _get_request_headers(self):

Undocumented

Returns
List[Tuple[str, str]]Undocumented
def check_request_url(self):

Undocumented

Returns
boolUndocumented
def close(self, reason, errors=None, from_protocol=False):
Based on the reason sent we will handle each case.
Parameters
reason:StreamCloseReasonUndocumented
errors:Optional[List[BaseException]]Undocumented
from​_protocol:boolUndocumented
def get_response(self):
Simply return a Deferred which fires when response from the asynchronous request is available
Returns
DeferredUndocumented
def initiate_request(self):

Undocumented

def receive_data(self, data, flow_controlled_length):

Undocumented

Parameters
data:bytesUndocumented
flow​_controlled​_length:intUndocumented
def receive_headers(self, headers):

Undocumented

Parameters
headers:List[HeaderTuple]Undocumented
def receive_window_update(self):
Flow control window size was changed. Send data that earlier could not be sent as we were blocked behind the flow control.
def reset_stream(self, reason=StreamCloseReason.RESET):
Close this stream by sending a RST_FRAME to the remote peer
Parameters
reason:StreamCloseReasonUndocumented
def send_data(self):

Called immediately after the headers are sent. Here we send all the data as part of the request.

If the content length is 0 initially then we end the stream immediately and wait for response data.

Warning: Only call this method when stream not closed from client side
and has initiated request already by sending HEADER frame. If not then stream will raise ProtocolError (raise by h2 state machine).
_deferred_response =

Undocumented

_download_maxsize =

Undocumented

_download_warnsize =

Undocumented

_protocol: H2ClientProtocol =

Undocumented

_request: Request =

Undocumented

_response: Dict =

Undocumented

metadata: Dict =

Undocumented

stream_id: int =

Undocumented

@property
_log_warnsize: bool =

Checks if we have received data which exceeds the download warnsize and whether we have not already logged about it.

Returns:
True if both the above conditions hold true False if any of the conditions is false