@@ -510,7 +510,8 @@ class Http3ApplicationImpl final : public Session::Application {
510510 code = error.code ();
511511 }
512512
513- int rv = nghttp3_conn_close_stream (*this , stream->id (), code);
513+ int rv = nghttp3_conn_close_stream2 (*this , NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET ,
514+ stream->id (), code, 0 );
514515 // If the call is successful, Http3Application::OnStreamClose callback will
515516 // be invoked when the stream is ready to be closed. We'll handle destroying
516517 // the actual Stream object there.
@@ -875,16 +876,31 @@ class Http3ApplicationImpl final : public Session::Application {
875876 return Http3ConnectionPointer (conn);
876877 }
877878
878- void OnStreamClose (Stream* stream, error_code app_error_code) {
879- if (app_error_code != NGHTTP3_H3_NO_ERROR ) {
879+ void OnStreamClose (Stream* stream, uint32_t flags,
880+ error_code rx_app_error_code,
881+ error_code tx_app_error_code) {
882+ if (flags & NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET ) {
880883 Debug (&session (),
881884 " HTTP/3 application received stream close for stream %" PRIi64
882- " with code %" PRIu64,
885+ " with remote error code %" PRIu64,
883886 stream->id (),
884- app_error_code);
887+ rx_app_error_code);
888+ }
889+ if (flags & NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET ) {
890+ Debug (&session (),
891+ " HTTP/3 application send stream close for stream %" PRIi64
892+ " with error code %" PRIu64,
893+ stream->id (),
894+ tx_app_error_code);
885895 }
886896 auto direction = stream->direction ();
887- stream->Destroy (QuicError::ForApplication (app_error_code));
897+ if (flags & NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET ) {
898+ stream->Destroy (QuicError::ForApplication (rx_app_error_code));
899+ } else if (flags & NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET ) {
900+ stream->Destroy (QuicError::ForApplication (tx_app_error_code));
901+ } else {
902+ stream->Destroy ();
903+ }
888904 ExtendMaxStreams (EndpointLabel::REMOTE , direction, 1 );
889905 }
890906
@@ -1247,13 +1263,16 @@ class Http3ApplicationImpl final : public Session::Application {
12471263 }
12481264
12491265 static int on_stream_close (nghttp3_conn* conn,
1266+ uint32_t flags,
12501267 stream_id id,
1251- error_code app_error_code,
1268+ error_code rx_app_error_code,
1269+ error_code tx_app_error_code,
12521270 void * conn_user_data,
12531271 void * stream_user_data) {
12541272 NGHTTP3_CALLBACK_SCOPE (app);
12551273 if (auto stream = app.session ().FindStream (id)) {
1256- app.OnStreamClose (stream.get (), app_error_code);
1274+ app.OnStreamClose (stream.get (), flags, rx_app_error_code,
1275+ tx_app_error_code);
12571276 }
12581277 return NGTCP2_SUCCESS ;
12591278 }
@@ -1511,7 +1530,7 @@ class Http3ApplicationImpl final : public Session::Application {
15111530
15121531 static constexpr nghttp3_callbacks kCallbacks = {
15131532 on_acked_stream_data,
1514- on_stream_close,
1533+ nullptr , // nghttp3_stream_close (deprecated)
15151534 on_receive_data,
15161535 on_deferred_consume,
15171536 on_begin_headers,
@@ -1529,6 +1548,7 @@ class Http3ApplicationImpl final : public Session::Application {
15291548 on_end_origin,
15301549 on_rand,
15311550 on_receive_settings,
1551+ on_stream_close,
15321552 on_receive_wt_data,
15331553 on_wt_data_stream_open,
15341554 on_recv_wt_close_session};
0 commit comments