http2: send HEADER & DATA together if possible#11420
Closed
peppapighs wants to merge 3 commits intocurl:masterfrom
peppapighs:http2-coalesce-frames
Closed
http2: send HEADER & DATA together if possible#11420peppapighs wants to merge 3 commits intocurl:masterfrom peppapighs:http2-coalesce-frames
peppapighs wants to merge 3 commits intocurl:masterfrom
peppapighs:http2-coalesce-frames
Conversation
bagder
reviewed
Jul 11, 2023
Member
|
Thanks! |
bch
pushed a commit
to bch/curl
that referenced
this pull request
Jul 19, 2023
ptitSeb
pushed a commit
to wasix-org/curl
that referenced
this pull request
Sep 25, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is based on the conversation here.
When sending an HTTP/2 POST request, curl will always defer request body to a different TLS record (if SSL/TLS is enabled) and TCP packet. This problem is previously addressed in #6363.
Belows are network packets captured by Wireshark by running
SSLKEYLOGFILE=/tmp/sslkeylog.log src/curl -k "https://nghttp2.org" -d "moo":We can combine the TCP packet by disabling
TCP_NODELAY. Belows is a TCP packet sent by runningSSLKEYLOGFILE=/tmp/sslkeylog.log src/curl -k "https://nghttp2.org" -d "moo" --no-tcp-nodelay:As can be seen from the image above, curl still generates 2 TLS records for HEADER and DATA frames, respectively (ignore the first TLS record from MAGIC frame).
Therefore, this PR provides an optimization that allows request body to be sent together with request headers in a single TLS record and TCP packet if the body size is small enough. This is achieved by attaching request body to header data so that
h2_submit()can write the body directly after it has created a stream.Belows is a TCP packet sent by running
SSLKEYLOGFILE=/tmp/sslkeylog.log src/curl -k "https://nghttp2.org" -d "moo"with this change: