class documentation

class H2ClientProtocol(Protocol, TimeoutMixin):

View In Hierarchy

Undocumented

Constant IDLE​_TIMEOUT Undocumented
Method __init__ No summary
Method ​_check​_received​_data Checks for edge cases where the connection to remote fails without raising an appropriate H2Error
Method ​_handle​_events Private method which acts as a bridge between the events received from the HTTP/2 data and IH2EventsHandler
Method ​_lose​_connection​_with​_error Helper function to lose the connection with the error sent as a reason
Method ​_new​_stream Instantiates a new Stream object
Method ​_send​_pending​_requests Initiate all pending requests from the deque following FIFO We make sure that at any time {allowed_max_concurrent_streams} streams are active.
Method ​_write​_to​_transport Write data to the underlying transport connection from the HTTP2 connection instance if any
Method connection​_terminated Undocumented
Method connection​Lost Called by Twisted when the transport connection is lost. No need to write anything to transport here.
Method connection​Made Called by Twisted when the connection is established. We can start sending some data now: we should open with the connection preamble.
Method data​_received Undocumented
Method data​Received Undocumented
Method handshake​Completed Close the connection if it's not made via the expected protocol
Method pop​_stream Perform cleanup when a stream is closed
Method request Undocumented
Method response​_received Undocumented
Method settings​_acknowledged Undocumented
Method stream​_ended Undocumented
Method stream​_reset Undocumented
Method timeout​Connection Called when the connection times out. We lose the connection with TimeoutError
Method window​_updated Undocumented
Instance Variable ​_conn​_lost​_deferred Undocumented
Instance Variable ​_conn​_lost​_errors Undocumented
Instance Variable ​_pending​_request​_stream​_pool Undocumented
Instance Variable ​_stream​_id​_generator Undocumented
Instance Variable conn Undocumented
Instance Variable metadata Undocumented
Instance Variable streams Undocumented
Property allowed​_max​_concurrent​_streams No summary
Property h2​_connected Boolean to keep track of the connection status. This is used while initiating pending streams to make sure that we initiate stream only during active HTTP/2 Connection
IDLE_TIMEOUT: int =

Undocumented

Value
240
def __init__(self, uri, settings, conn_lost_deferred):
Arguments:
uri -- URI of the base url to which HTTP/2 Connection will be made.
uri is used to verify that incoming client requests have correct base URL.

settings -- Scrapy project settings conn_lost_deferred -- Deferred fires with the reason: Failure to notify

that connection was lost
Parameters
uri:URIUndocumented
settings:SettingsUndocumented
conn​_lost​_deferred:DeferredUndocumented
def _check_received_data(self, data):

Checks for edge cases where the connection to remote fails without raising an appropriate H2Error

Arguments:
data -- Data received from the remote
Parameters
data:bytesUndocumented
def _handle_events(self, events):

Private method which acts as a bridge between the events received from the HTTP/2 data and IH2EventsHandler

Arguments:
events -- A list of events that the remote peer triggered by sending data
Parameters
events:List[Event]Undocumented
def _lose_connection_with_error(self, errors):
Helper function to lose the connection with the error sent as a reason
Parameters
errors:List[BaseException]Undocumented
def _new_stream(self, request, spider):
Instantiates a new Stream object
Parameters
request:RequestUndocumented
spider:SpiderUndocumented
Returns
StreamUndocumented
def _send_pending_requests(self):
Initiate all pending requests from the deque following FIFO We make sure that at any time {allowed_max_concurrent_streams} streams are active.
def _write_to_transport(self):
Write data to the underlying transport connection from the HTTP2 connection instance if any
def connection_terminated(self, event):

Undocumented

Parameters
event:ConnectionTerminatedUndocumented
def connectionLost(self, reason=connectionDone):
Called by Twisted when the transport connection is lost. No need to write anything to transport here.
Parameters
reason:FailureUndocumented
def connectionMade(self):
Called by Twisted when the connection is established. We can start sending some data now: we should open with the connection preamble.
def data_received(self, event):

Undocumented

Parameters
event:DataReceivedUndocumented
def dataReceived(self, data):

Undocumented

Parameters
data:bytesUndocumented
def handshakeCompleted(self):
Close the connection if it's not made via the expected protocol
def pop_stream(self, stream_id):
Perform cleanup when a stream is closed
Parameters
stream​_id:intUndocumented
Returns
StreamUndocumented
def request(self, request, spider):

Undocumented

Parameters
request:RequestUndocumented
spider:SpiderUndocumented
Returns
DeferredUndocumented
def response_received(self, event):

Undocumented

Parameters
event:ResponseReceivedUndocumented
def settings_acknowledged(self, event):

Undocumented

Parameters
event:SettingsAcknowledgedUndocumented
def stream_ended(self, event):

Undocumented

Parameters
event:StreamEndedUndocumented
def stream_reset(self, event):

Undocumented

Parameters
event:StreamResetUndocumented
def timeoutConnection(self):
Called when the connection times out. We lose the connection with TimeoutError
def window_updated(self, event):

Undocumented

Parameters
event:WindowUpdatedUndocumented
_conn_lost_deferred =

Undocumented

_conn_lost_errors: List[BaseException] =

Undocumented

_pending_request_stream_pool: deque =

Undocumented

_stream_id_generator =

Undocumented

conn =

Undocumented

metadata: Dict =

Undocumented

streams: Dict[int, Stream] =

Undocumented

@property
allowed_max_concurrent_streams: int =
We keep total two streams for client (sending data) and server side (receiving data) for a single request. To be safe we choose the minimum. Since this value can change in event RemoteSettingsChanged we make variable a property.
@property
h2_connected: bool =
Boolean to keep track of the connection status. This is used while initiating pending streams to make sure that we initiate stream only during active HTTP/2 Connection