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

Commit cb86199

Browse files
committed
Pass _send_outstanding_data instead of _send_cb to stream constructor and adjust call in stream accordingly
1 parent bb70299 commit cb86199

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

hyper/http20/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ def _new_stream(self, stream_id=None, local_closed=False):
577577
stream_id or self.next_stream_id,
578578
self.__wm_class(DEFAULT_WINDOW_SIZE),
579579
self._conn,
580-
self._send_cb,
580+
self._send_outstanding_data,
581581
self._recv_cb,
582582
self._stream_close_cb,
583583
)

hyper/http20/stream.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def send_headers(self, end_stream=False):
9696
headers = self.get_headers()
9797
with self._conn as conn:
9898
conn.send_headers(self.stream_id, headers, end_stream)
99-
self._send_cb(conn.data_to_send())
99+
self._send_cb()
100100

101101
if end_stream:
102102
self.local_closed = True
@@ -191,7 +191,7 @@ def receive_data(self, event):
191191
conn.increment_flow_control_window(
192192
increment, stream_id=self.stream_id
193193
)
194-
self._send_cb(conn.data_to_send())
194+
self._send_cb()
195195

196196
def receive_end_stream(self, event):
197197
"""
@@ -280,16 +280,18 @@ def close(self, error_code=None):
280280
# FIXME: I think this is overbroad, but for now it's probably ok.
281281
if not (self.remote_closed and self.local_closed):
282282
with self._conn as conn:
283+
send = False
284+
283285
try:
284286
conn.reset_stream(self.stream_id, error_code or 0)
285287
except h2.exceptions.ProtocolError:
286-
# If for any reason we can't reset the stream, just tolerate
287-
# it.
288+
# If for any reason we can't reset the stream, just
289+
# tolerate it.
288290
pass
289291
else:
290-
self._send_cb(
291-
conn.data_to_send(), tolerate_peer_gone=True
292-
)
292+
send = True
293+
if send:
294+
self._send_cb(tolerate_peer_gone=True)
293295
self.remote_closed = True
294296
self.local_closed = True
295297

@@ -329,7 +331,7 @@ def _send_chunk(self, data, final):
329331
conn.send_data(
330332
stream_id=self.stream_id, data=data, end_stream=end_stream
331333
)
332-
self._send_cb(conn.data_to_send())
334+
self._send_cb()
333335

334336
if end_stream:
335337
self.local_closed = True

0 commit comments

Comments
 (0)