File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -143,10 +143,14 @@ def handle_request(self, request: Request) -> Response:
143143 # a GOAWAY event. Other flows of control may then raise
144144 # a protocol error at any point they interact with the 'h2_state'.
145145 #
146- # In this case we'll have stored the event, and should raise
147- # it as a RemoteProtocolError.
146+ # In this case we'll have stored the event, and should raise it.
148147 if self ._connection_error_event :
149- raise RemoteProtocolError (self ._connection_error_event )
148+ if isinstance (
149+ self ._connection_error_event , h2 .events .ConnectionTerminated
150+ ):
151+ raise ConnectionNotAvailable (self ._connection_error_event )
152+ else :
153+ raise RemoteProtocolError (self ._connection_error_event )
150154 # If h2 raises a protocol error in some other state then we
151155 # must somehow have made a protocol violation.
152156 raise LocalProtocolError (exc ) # pragma: nocover
@@ -279,7 +283,7 @@ def _receive_events(
279283 ) -> None :
280284 with self ._read_lock :
281285 if self ._connection_error_event is not None : # pragma: nocover
282- raise RemoteProtocolError (self ._connection_error_event )
286+ raise ConnectionNotAvailable (self ._connection_error_event )
283287
284288 # This conditional is a bit icky. We don't want to block reading if we've
285289 # actually got an event to return for a given stream. We need to do that
Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ def test_http2_connection_closed():
8383 with pytest .raises (RemoteProtocolError ):
8484 conn .request ("GET" , "https://example.com/" )
8585
86+ with pytest .raises (ConnectionNotAvailable ):
87+ conn .request ("GET" , "https://example.com/" )
88+
8689 assert not conn .is_available ()
8790
8891
@@ -219,7 +222,7 @@ def test_http2_connection_with_goaway():
219222 with HTTP2Connection (origin = origin , stream = stream ) as conn :
220223 with pytest .raises (RemoteProtocolError ):
221224 conn .request ("GET" , "https://example.com/" )
222- with pytest .raises (RemoteProtocolError ):
225+ with pytest .raises (ConnectionNotAvailable ):
223226 conn .request ("GET" , "https://example.com/" )
224227
225228
You can’t perform that action at this time.
0 commit comments