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

Commit

Permalink
Merge pull request #276 from plucury/development
Browse files Browse the repository at this point in the history
Reset connection state when it was closed even its _sock object is None
  • Loading branch information
Lukasa committed Aug 20, 2016
2 parents 2146b71 + 4256291 commit fd66a58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hyper/http20/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def close(self, error_code=None):

if self._sock is not None:
self._sock.close()
self.__init_state()
self.__init_state()

def _send_outstanding_data(self, tolerate_peer_gone=False,
send_empty=True):
Expand Down
14 changes: 14 additions & 0 deletions test/test_hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import h2.settings

from h2.frame_buffer import FrameBuffer
from h2.connection import ConnectionState
from hyperframe.frame import (
Frame, DataFrame, RstStreamFrame, SettingsFrame, PushPromiseFrame,
WindowUpdateFrame, HeadersFrame, ContinuationFrame, GoAwayFrame,
Expand Down Expand Up @@ -275,6 +276,19 @@ def test_closed_connections_are_reset(self):
assert c.recent_stream is None
assert c.next_stream_id == 1
assert c.window_manager is not wm
with c._conn as conn:
assert conn.state_machine.state == ConnectionState.IDLE
origin_h2_conn = conn

c.close()
assert c._sock is None
assert not c.streams
assert c.recent_stream is None
assert c.next_stream_id == 1
assert c.window_manager is not wm
with c._conn as conn:
assert conn.state_machine.state == ConnectionState.IDLE
assert conn != origin_h2_conn

def test_streams_removed_on_close(self):
# Create content for read from socket
Expand Down

0 comments on commit fd66a58

Please sign in to comment.