From b27b002a3f0fa47a7e9a8d0dfbcd6ee8abe9b3f3 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 21 Nov 2015 15:40:05 +0900 Subject: [PATCH] python: Use nghttp2_session_get_stream_remote_close --- python/cnghttp2.pxd | 10 +--------- python/nghttp2.pyx | 7 +++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/python/cnghttp2.pxd b/python/cnghttp2.pxd index d6ddc950..3c829f82 100644 --- a/python/cnghttp2.pxd +++ b/python/cnghttp2.pxd @@ -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) diff --git a/python/nghttp2.pyx b/python/nghttp2.pyx index ab991d63..4ebbf178 100644 --- a/python/nghttp2.pyx +++ b/python/nghttp2.pyx @@ -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