python: Send RST_STREAM if remote side is not closed and response finished
This commit is contained in:
parent
63a50b1ccf
commit
8481bc6e93
|
@ -288,6 +288,18 @@ cdef extern from 'nghttp2/nghttp2.h':
|
||||||
|
|
||||||
const char* nghttp2_strerror(int lib_error_code)
|
const char* nghttp2_strerror(int lib_error_code)
|
||||||
|
|
||||||
|
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_hd_deflate_new(nghttp2_hd_deflater **deflater_ptr,
|
int nghttp2_hd_deflate_new(nghttp2_hd_deflater **deflater_ptr,
|
||||||
size_t deflate_hd_table_bufsize_max)
|
size_t deflate_hd_table_bufsize_max)
|
||||||
|
|
||||||
|
|
|
@ -539,6 +539,12 @@ cdef ssize_t data_source_read(cnghttp2.nghttp2_session *session,
|
||||||
|
|
||||||
if flag == DATA_EOF:
|
if flag == DATA_EOF:
|
||||||
data_flags[0] = cnghttp2.NGHTTP2_DATA_FLAG_EOF
|
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)
|
||||||
elif flag != DATA_OK:
|
elif flag != DATA_OK:
|
||||||
return cnghttp2.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE
|
return cnghttp2.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue