Reza Shahbazi
Reza Shahbazi

Reputation: 451

nghttp2: POST payload

I am trying to POST a dataset using nghttp2. I noticed that the nghttp2_submit_request sends the stream_user_data just through header frame not the data frame.

What's the convenient method to submit a data (json or binary) using nghttp2? Should I use nghttp2_submit_data or use asio session.submit?

Upvotes: 1

Views: 1914

Answers (1)

Tatsuhiro Tsujikawa
Tatsuhiro Tsujikawa

Reputation: 404

The stream_user_data is just a opaque pointer, and solely used by application to pass arbitrary data it wants to use in callback functions.

The expected way to send data is implement nghttp2_data_source_read_callback to send data in non-blocking way. And set it to nghttp2_data_provider, and pass it to nghttp2_submit_request.

This is the same way to send response from server side. Check https://nghttp2.org/documentation/tutorial-server.html to see how to implement nghttp2_data_source_read_callback.

Upvotes: 1

Related Questions