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: Pontakorn Prasertsuk via curl-library <curl-library_at_lists.haxx.se>
Date: Wed, 21 Jun 2023 15:56:43 +0800

Hi Stefan,

I have a POST body with length 10. The header `Content-length: 10` is
present in the HEADER frame of my request. Referring to the image, the POST
body is in the third packet after the HEADER packet (with SETTINGS packet
from server and ACK packet from the client in between). It should be
possible to fit the DATA frame into the first packet with the HEADER frame
but I cannot find a way to do it in libcurl.

Regards,
Pontakorn

On Wed, Jun 21, 2023 at 3:25 PM Stefan Eissing <stefan.eissing_at_greenbytes.de>
wrote:

>
>
> > Am 21.06.2023 um 08:04 schrieb Pontakorn Prasertsuk via curl-library <
> curl-library_at_lists.haxx.se>:
> >
> > 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,
> Stefan
>
> >
> > Regards,
> > Pontakorn
> > --
> > Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
> > Etiquette: https://curl.se/mail/etiquette.html
>
>


-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-06-21