python: Use nghttp2_session_get_stream_remote_close

This commit is contained in:
Tatsuhiro Tsujikawa 2015-11-21 15:40:05 +09:00
parent 8481bc6e93
commit b27b002a3f
2 changed files with 4 additions and 13 deletions

View File

@ -290,15 +290,7 @@ cdef extern from 'nghttp2/nghttp2.h':
int nghttp2_session_check_server_session(nghttp2_session *session)
ctypedef struct nghttp2_stream:
pass
nghttp2_stream *nghttp2_session_find_stream(nghttp2_session *session, int32_t stream_id)
ctypedef enum nghttp2_stream_proto_state:
NGHTTP2_STREAM_STATE_OPEN
nghttp2_stream_proto_state nghttp2_stream_get_state(nghttp2_stream *stream)
int nghttp2_session_get_stream_remote_close(nghttp2_session *session, int32_t stream_id)
int nghttp2_hd_deflate_new(nghttp2_hd_deflater **deflater_ptr,
size_t deflate_hd_table_bufsize_max)

View File

@ -541,10 +541,9 @@ cdef ssize_t data_source_read(cnghttp2.nghttp2_session *session,
data_flags[0] = cnghttp2.NGHTTP2_DATA_FLAG_EOF
if cnghttp2.nghttp2_session_check_server_session(session):
# Send RST_STREAM if remote is not closed yet
cstrm = cnghttp2.nghttp2_session_find_stream(session, stream_id)
state = cnghttp2.nghttp2_stream_get_state(cstrm)
if state == cnghttp2.NGHTTP2_STREAM_STATE_OPEN:
http2._rst_stream(stream_id)
if cnghttp2.nghttp2_session_get_stream_remote_close(
session, stream_id) == 0:
http2._rst_stream(stream_id, cnghttp2.NGHTTP2_NO_ERROR)
elif flag != DATA_OK:
return cnghttp2.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE