Skip to content

nghttp2_submit_rst_stream after nghttp2_submit_response causes response headers to be dropped #692

@mattklein123

Description

@mattklein123

Hi,

Using 1.14.1.

I noticed today that if I do the following sequence:

  1. nghttp2_submit_response(...)
  2. nghttp2_submit_rst_stream(...)
  3. nghttp2_session_send(...)

The headers frame for the stream is dropped during send. The use case is I want to respond before the request is complete, so I do a full response, then reset the stream so the client cannot send any more incoming stream frames. However I do want the client to see the response headers.

If I do nghttp2_session_send() before nghttp2_submit_rst_stream() things work as expected.

What are your thoughts here in terms of how the library should handle this? The main issue for me is that I do a bunch of things in callbacks, and AFAIK it's not recommended to call nghttp2_session_send() from within a callback, and furthermore it make error handling for me a lot more complicated as I use exceptions. So right now I call nghttp2_session_send() after dispatching and all callbacks have been called.

I can handle this in the app code potentially, but wanted to see whether you think this is the right library behavior.

For reference, here is Envoy's HTTP/2 codec code which uses nghttp2 (happy that I can finally share this):
https://github.com/lyft/envoy/blob/master/source/common/http/http2/codec_impl.cc

Thanks,
Matt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions