Add API to check half-closed state for both direction of stream
This commit is contained in:
parent
119fb05cc2
commit
4b6f124b7e
|
@ -1995,6 +1995,25 @@ int32_t nghttp2_session_get_effective_local_window_size
|
||||||
int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session* session,
|
int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session* session,
|
||||||
int32_t stream_id);
|
int32_t stream_id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* Returns 1 if local peer half closed the given stream |stream_id|.
|
||||||
|
* Returns 0 if it did not. Returns -1 if no such stream exists.
|
||||||
|
*/
|
||||||
|
int nghttp2_session_get_stream_local_close(nghttp2_session* session,
|
||||||
|
int32_t stream_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* Returns 1 if remote peer half closed the given stream |stream_id|.
|
||||||
|
* Returns 0 if it did not. Returns -1 if no such stream exists.
|
||||||
|
*/
|
||||||
|
int nghttp2_session_get_stream_remote_close(nghttp2_session* session,
|
||||||
|
int32_t stream_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
*
|
*
|
||||||
|
|
|
@ -5627,3 +5627,31 @@ int nghttp2_session_upgrade(nghttp2_session *session,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nghttp2_session_get_stream_local_close(nghttp2_session* session,
|
||||||
|
int32_t stream_id)
|
||||||
|
{
|
||||||
|
nghttp2_stream *stream;
|
||||||
|
|
||||||
|
stream = nghttp2_session_get_stream(session, stream_id);
|
||||||
|
|
||||||
|
if(!stream) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (stream->shut_flags & NGHTTP2_SHUT_WR) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nghttp2_session_get_stream_remote_close(nghttp2_session* session,
|
||||||
|
int32_t stream_id)
|
||||||
|
{
|
||||||
|
nghttp2_stream *stream;
|
||||||
|
|
||||||
|
stream = nghttp2_session_get_stream(session, stream_id);
|
||||||
|
|
||||||
|
if(!stream) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (stream->shut_flags & NGHTTP2_SHUT_RD) != 0;
|
||||||
|
}
|
||||||
|
|
|
@ -67,8 +67,7 @@ Downstream::Downstream(Upstream *upstream, int stream_id, int priority)
|
||||||
request_http2_expect_body_(false),
|
request_http2_expect_body_(false),
|
||||||
chunked_response_(false),
|
chunked_response_(false),
|
||||||
response_connection_close_(false),
|
response_connection_close_(false),
|
||||||
response_header_key_prev_(false),
|
response_header_key_prev_(false)
|
||||||
rst_stream_after_end_stream_(false)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Downstream::~Downstream()
|
Downstream::~Downstream()
|
||||||
|
@ -796,14 +795,4 @@ void Downstream::set_response_rst_stream_error_code
|
||||||
response_rst_stream_error_code_ = error_code;
|
response_rst_stream_error_code_ = error_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Downstream::get_rst_stream_after_end_stream() const
|
|
||||||
{
|
|
||||||
return rst_stream_after_end_stream_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Downstream::set_rst_stream_after_end_stream(bool f)
|
|
||||||
{
|
|
||||||
rst_stream_after_end_stream_ = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
|
|
@ -282,10 +282,6 @@ private:
|
||||||
bool chunked_response_;
|
bool chunked_response_;
|
||||||
bool response_connection_close_;
|
bool response_connection_close_;
|
||||||
bool response_header_key_prev_;
|
bool response_header_key_prev_;
|
||||||
|
|
||||||
// If true, RST_STREAM with NGHTTP2_NO_ERROR is issued after
|
|
||||||
// response is closed with END_STREAM.
|
|
||||||
bool rst_stream_after_end_stream_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
|
|
@ -1013,9 +1013,7 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
|
||||||
if(!downstream->get_upgraded()) {
|
if(!downstream->get_upgraded()) {
|
||||||
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
|
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
|
||||||
|
|
||||||
if(downstream->get_rst_stream_after_end_stream() &&
|
if(nghttp2_session_get_stream_remote_close(session, stream_id) == 0) {
|
||||||
downstream->get_request_state() != Downstream::MSG_COMPLETE) {
|
|
||||||
|
|
||||||
upstream->rst_stream(downstream, NGHTTP2_NO_ERROR);
|
upstream->rst_stream(downstream, NGHTTP2_NO_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1079,8 +1077,6 @@ int Http2Upstream::error_reply(Downstream *downstream,
|
||||||
status_code, downstream);
|
status_code, downstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
downstream->set_rst_stream_after_end_stream(true);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue