curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: HTTP/2 deferring DATA frame to another TCP packet

From: Stefan Eissing via curl-library <>
Date: Wed, 21 Jun 2023 09:25:30 +0200

> Am 21.06.2023 um 08:04 schrieb Pontakorn Prasertsuk via curl-library <>:
> Hi,
> I am currently testing HTTP/2 connection to my local server using Curl i.e. running:
> SSLKEYLOGFILE=/tmp/sslkeylog.log src/curl --location "https://localhost:8000" --insecure --http2 --data "1234567890" -H "Content-type: text/plain" -v
> The packets sent are as shown belows:<curl_http2_post_request.png>
> The DATA frame is on a different packet from the HEADER frame.
> However, sending HEADER and DATA frames together should be possible. Belows are the packets sent using my own HTTP/2 client:
> <custom_http2_post_request.png>
> I have looked into libcurl `http2.c` and it seems that curl performs `nghttp2_submit_request` to send headers with callback deferring the DATA frame. The DATA frame then is sent on a second call to `cf_h2_send`, causing the DATA frame to be on a different TCP packet from the HEADER frame.
> My questions are:
> 1. What are the ideas behind this design? Is this design deliberate? If so, are there any ways I can send HTTP/2 requests with HEADER and DATA frames in the same packet? We want to do so to achieve higher throughput while still using libcurl.
> 2. Otherwise, what modification should be required for libcurl to support such operation?

Most POST request have a body. That is the reason for sending the HEADER frame without EOF and wait for the subsequent body send to end the request.

You seem to send POSTs without body. If curl can know it will be empty, it would be possible to optimize for this. What is the "Content-Length" header on your requests, if there is one?

Kind Regards,

> Regards,
> Pontakorn
> --
> Unsubscribe:
> Etiquette:

Received on 2023-06-21