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 #270 from nateprewitt/265_remove_stream_on_close
Browse files Browse the repository at this point in the history
removing stream from recent_recv_streams on clean close
  • Loading branch information
Lukasa committed Aug 16, 2016
2 parents e7c4cb5 + 90b43a3 commit 689e4ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions hyper/http20/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ def _stream_close_cb(self, stream_id):
"""
try:
del self.streams[stream_id]
self.recent_recv_streams.discard(stream_id)
except KeyError:
pass

Expand Down
24 changes: 24 additions & 0 deletions test/test_hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ def test_closed_connections_are_reset(self):
assert c.next_stream_id == 1
assert c.window_manager is not wm

def test_streams_removed_on_close(self):
# Create content for read from socket
e = Encoder()
h1 = HeadersFrame(1)
h1.data = e.encode([(':status', 200), ('content-type', 'foo/bar')])
h1.flags |= set(['END_HEADERS', 'END_STREAM'])
sock = DummySocket()
sock.buffer = BytesIO(h1.serialize())

c = HTTP20Connection('www.google.com')
c._sock = sock
stream_id = c.request('GET', '/')

# Create reference to current recent_recv_streams set
recent_recv_streams = c.recent_recv_streams
streams = c.streams

resp = c.get_response(stream_id=stream_id)
assert stream_id in recent_recv_streams
assert stream_id in streams
resp.read()
assert stream_id not in recent_recv_streams
assert stream_id not in streams

def test_connection_no_window_update_on_zero_length_data_frame(self):
# Prepare a socket with a data frame in it that has no length.
sock = DummySocket()
Expand Down

0 comments on commit 689e4ce

Please sign in to comment.