def __init__(self, handler, request): self.handler = handler self.wasc = handler.wasc self.request = request self.channel = request.channel # replace fifo with supporting priority, ready, removing if self.wasc.numthreads: self.channel.producer_fifo = http2_producer_ts_fifo() else: self.channel.producer_fifo = http2_producer_fifo() self.conn = H2Connection(H2Configuration(client_side=False)) self.frame_buf = self.conn.incoming_buffer self.frame_buf.max_frame_size = self.conn.max_inbound_frame_size self.data_length = 0 self.current_frame = None self.rfile = BytesIO() self.buf = b"" self.requests = {} self.priorities = {} self.promises = {} self._closed = False self._got_preamble = False self._plock = threading.Lock() # for self.conn self._clock = threading.Lock() # for self.x
def __init__ (self, handler, request): self._default_varialbes (handler, request) self.conn = H2Connection (H2Configuration (client_side = False)) self._frame_buf = self.conn.incoming_buffer self._frame_buf.max_frame_size = self.conn.max_inbound_frame_size self._data_length = 0 self._current_frame = None self._rfile = BytesIO () self._buf = b"" self._got_preamble = False
def __init_state(self): """ Initializes the 'mutable state' portions of the HTTP/2 connection object. This method exists to enable HTTP20Connection objects to be reused if they're closed, by resetting the connection object to its basic state whenever it ends up closed. Any situation that needs to recreate the connection can call this method and it will be done. This is one of the only methods in hyper that is truly private, as users should be strongly discouraged from messing about with connection objects themselves. """ config1 = H2Configuration( client_side=True, header_encoding='utf-8', validate_outbound_headers=False, validate_inbound_headers=False, ) self._conn = _LockedObject(h2.connection.H2Connection(config=config1)) # Streams are stored in a dictionary keyed off their stream IDs. We # also save the most recent one for easy access without having to walk # the dictionary. # # We add a set of all streams that we or the remote party forcefully # closed with RST_STREAM, to avoid encountering issues where frames # were already in flight before the RST was processed. # # Finally, we add a set of streams that recently received data. When # using multiple threads, this avoids reading on threads that have just # acquired the I/O lock whose streams have already had their data read # for them by prior threads. self.streams = {} self.recent_stream = None self.next_stream_id = 1 self.reset_streams = set() self.recent_recv_streams = set() # The socket used to send data. self._sock = None # Instantiate a window manager. #self.window_manager = self.__wm_class(65535) return