class documentation

class Stream: (source)

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__ 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
Method __repr__ 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 metadata Undocumented
Instance Variable stream_id 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
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
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: int, request: Request, protocol: H2ClientProtocol, download_maxsize: int = 0, download_warnsize: int = 0): (source)

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

def __repr__(self) -> str: (source)

Undocumented

def check_request_url(self) -> bool: (source)

Undocumented

def close(self, reason: StreamCloseReason, errors: Optional[List[BaseException]] = None, from_protocol: bool = False): (source)

Based on the reason sent we will handle each case.

def get_response(self) -> Deferred: (source)

Simply return a Deferred which fires when response from the asynchronous request is available

def initiate_request(self): (source)

Undocumented

def receive_data(self, data: bytes, flow_controlled_length: int): (source)

Undocumented

def receive_headers(self, headers: List[HeaderTuple]): (source)

Undocumented

def receive_window_update(self): (source)

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 = StreamCloseReason.RESET): (source)

Close this stream by sending a RST_FRAME to the remote peer

def send_data(self): (source)

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).

metadata: Dict = (source)

Undocumented

stream_id: int = (source)

Undocumented

def _fire_response_deferred(self): (source)

Builds response from the self._response dict and fires the response deferred callback with the generated response instance

def _get_request_headers(self) -> List[Tuple[str, str]]: (source)

Undocumented

_deferred_response = (source)

Undocumented

_download_maxsize = (source)

Undocumented

_download_warnsize = (source)

Undocumented

Undocumented

_request: Request = (source)

Undocumented

_response: Dict = (source)

Undocumented

@property
_log_warnsize: bool = (source)

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