python-hyper / h2

HTTP/2 State-Machine based protocol implementation
https://h2.readthedocs.io/en/stable
MIT License
963 stars 151 forks source link

H2Connection.outbound_flow_control_window is not updated in the initial SETTINGS exchange #1240

Closed drv1234 closed 3 years ago

drv1234 commented 3 years ago

Hi, as I see the H2Connection.outbound_flow_control_window is not updated in the initial SETTINGS exchange. I put these lines after event handling loop:

           events = self.conn.receive_data(data)
            for event in events:
                if isinstance(event, ResponseReceived):
                    self.handle_response_received(event)
                elif isinstance(event, DataReceived):
                    self.handle_data_received(event)

: : data = self.conn.data_to_send() if data: self.writer.write(data)

            **print('self.conn.outbound_flow_control_window:', self.conn.outbound_flow_control_window)
            print('self.conn.remote_settings.initial_window_size:', self.conn.remote_settings.initial_window_size)**

and I see that _self.conn.outbound_flow_controlwindow is not updated according to the initial SETTINGS frame but _self.conn.remote_settings.initial_windowsize is correct.

The result is that even the remote side can handle more data so does not send any WINDOW_UPDATE but the local peer will not send any data because it thinks that remote side is full

drv1234 commented 3 years ago

Checking the source code and the RFC, it turned out it is not a bug.

def _flow_control_change_from_settings(self, old_value, new_value):
    """
    Update flow control windows in response to a change in the value of
    SETTINGS_INITIAL_WINDOW_SIZE.

    When this setting is changed, it automatically updates all flow control
    windows by the delta in the settings values. Note that it does not
    increment the *connection* flow control window, per section 6.9.2 of
    RFC 7540.
    """