How to use HTTP/2's pushing features with curl?
Asked Answered
L

1

8

I have been looking into ways to use HTTP/2's pushing features, in order to reduce the number of issued GET requests and the average perceived delay in specific client-server implementations. The existing client heavily relies on the use of curl to issue GET requests, and I need to be able to reuse the current implementation. Recent versions of curl provide support for HTTP/2, relying on the underlying nghttp2 module. Using the existing nghttp2 server:

nghttpd -d /var/www/html/ 3000 local.key local.crt

both nghttp and curl can be used to get an example text file's content:

nghttp https://localhost:3000/text.txt
This is some sample text.

curl https://localhost:3000/text.txt -k --http2
This is some sample text.

Using nghttp2's pushing feature however, where another text file is pushed along:

nghttpd -d /var/www/html/ -p/text.txt=/text2.txt 3000 local.key local.crt

curl seems not capable of dealing with the pushed resource:

nghttp https://localhost:3000/bbb/text.txt
This is some sample text.
This is some sample text as well.

curl https://localhost:3000/text.txt -k --http2 -v
...
* nghttp2_session_mem_recv() returns 268
* before_frame_send() was called
* on_frame_send() was called
* on_stream_close() was called, error_code = 1
* before_frame_send() was called
* on_frame_send() was called
* on_stream_close() was called, error_code = 1
* Connection #0 to host localhost left intact

Indeed, at server side, two resets are received for the two opened streams:

[id=1] [331.593] recv RST_STREAM frame <length=4, flags=0x00, stream_id=1>
      (error_code=PROTOCOL_ERROR(0x01))
[id=1] [331.594] recv RST_STREAM frame <length=4, flags=0x00, stream_id=2>
      (error_code=PROTOCOL_ERROR(0x01))
[id=1] [331.594] closed

Is there a way to use curl with the HTTP/2 pushing features?

Linebreeding answered 14/12, 2014 at 16:38 Comment(0)
D
6

curl (the command line tool) doesn't support HTTP/2 push (yet).

You can only make use of it when doing HTTP/2 with libcurl and not the command line tool.

Dipsomaniac answered 15/12, 2014 at 9:31 Comment(5)
Does curl support the HTTP/2 push as of today?Ginetteginevra
@ldclakmal I think it does: curl.se/docs/http2.html I confirm on some of my installations (7.52.1 on a pi3) that it also fetches pushed resources. On some others though it doesn't (e.g 7.68.0 on Ubuntu 20, or 7.76.0 on windows) so I'm not sure what is going on there.Cataplasm
curl, the command line tool, still does not support HTTP/2 push.Dipsomaniac
And how about alternative with command line?Reseda
Does curl support the HTTP/2 push as of today?Jagannath

© 2022 - 2024 — McMap. All rights reserved.