nghttpx: Implement http_reset_stream and http_send_stop_sending

This commit is contained in:
Tatsuhiro Tsujikawa 2021-08-17 19:05:53 +09:00
parent b0548b4944
commit 37bd9ffc48
2 changed files with 38 additions and 2 deletions

View File

@ -1904,18 +1904,52 @@ namespace {
int http_send_stop_sending(nghttp3_conn *conn, int64_t stream_id,
uint64_t app_error_code, void *user_data,
void *stream_user_data) {
auto upstream = static_cast<Http3Upstream *>(user_data);
if (upstream->http_send_stop_sending(stream_id, app_error_code) != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE;
}
return 0;
}
} // namespace
int Http3Upstream::http_send_stop_sending(int64_t stream_id,
uint64_t app_error_code) {
auto rv = ngtcp2_conn_shutdown_stream_read(conn_, stream_id, app_error_code);
if (ngtcp2_err_is_fatal(rv)) {
LOG(ERROR) << "ngtcp2_conn_shutdown_stream_read: " << ngtcp2_strerror(rv);
return -1;
}
return 0;
}
namespace {
int http_reset_stream(nghttp3_conn *conn, int64_t stream_id,
uint64_t app_error_code, void *user_data,
void *stream_user_data) {
auto upstream = static_cast<Http3Upstream *>(user_data);
if (upstream->http_reset_stream(stream_id, app_error_code) != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE;
}
return 0;
}
} // namespace
int Http3Upstream::http_reset_stream(int64_t stream_id,
uint64_t app_error_code) {
auto rv = ngtcp2_conn_shutdown_stream_write(conn_, stream_id, app_error_code);
if (ngtcp2_err_is_fatal(rv)) {
LOG(ERROR) << "ngtcp2_conn_shutdown_stream_write: " << ngtcp2_strerror(rv);
return -1;
}
return 0;
}
int Http3Upstream::setup_httpconn() {
int rv;
@ -1934,9 +1968,9 @@ int Http3Upstream::setup_httpconn() {
nullptr, // begin_trailers
nullptr, // recv_trailer
nullptr, // end_trailers
http_send_stop_sending,
shrpx::http_send_stop_sending,
shrpx::http_end_stream,
http_reset_stream,
shrpx::http_reset_stream,
};
nghttp3_settings settings;

View File

@ -138,6 +138,8 @@ public:
const std::vector<nghttp3_nv> &nva) const;
int http_acked_stream_data(Downstream *downstream, size_t datalen);
int http_shutdown_stream_read(int64_t stream_id);
int http_reset_stream(int64_t stream_id, uint64_t app_error_code);
int http_send_stop_sending(int64_t stream_id, uint64_t app_error_code);
private:
ClientHandler *handler_;