Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit e2d2e63

Browse files
committed
the connection state wasn't reseted while closed a connection without sock
1 parent 2146b71 commit e2d2e63

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

hyper/http20/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def close(self, error_code=None):
450450

451451
if self._sock is not None:
452452
self._sock.close()
453-
self.__init_state()
453+
self.__init_state()
454454

455455
def _send_outstanding_data(self, tolerate_peer_gone=False,
456456
send_empty=True):

test/test_hyper.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import h2.settings
33

44
from h2.frame_buffer import FrameBuffer
5+
from h2.connection import ConnectionState
56
from hyperframe.frame import (
67
Frame, DataFrame, RstStreamFrame, SettingsFrame, PushPromiseFrame,
78
WindowUpdateFrame, HeadersFrame, ContinuationFrame, GoAwayFrame,
@@ -275,6 +276,18 @@ def test_closed_connections_are_reset(self):
275276
assert c.recent_stream is None
276277
assert c.next_stream_id == 1
277278
assert c.window_manager is not wm
279+
with c._conn as conn:
280+
assert conn.state_machine.state == ConnectionState.IDLE
281+
282+
c = HTTP20Connection('www.google.com')
283+
c.close()
284+
assert c._sock is None
285+
assert not c.streams
286+
assert c.recent_stream is None
287+
assert c.next_stream_id == 1
288+
assert c.window_manager is not wm
289+
with c._conn as conn:
290+
assert conn.state_machine.state == ConnectionState.IDLE
278291

279292
def test_streams_removed_on_close(self):
280293
# Create content for read from socket

0 commit comments

Comments
 (0)