hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.57k stars 1.6k forks source link

Trailers support in C API #2699

Open bagder opened 2 years ago

bagder commented 2 years ago

I'm making curl use hyper instead of its native HTTP code.

curl supports trailers but I find no API to get them provided from hyper so until it does, I can't make curl+hyper match the native implementation in features.

Sample HTTP/1.1 response below. I want the chunky-trailer: header data part.

HTTP/1.1 200 funky chunky!
Server: fakeit/0.9 fakeitbad/1.0
Transfer-Encoding: chunked
Trailer: chunky-trailer

40
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
30
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
21
cccccccccccccccccccccccccccccccc

0
chunky-trailer: header data
seanmonstar commented 2 years ago

Ah, sure. We do have support for trailers on the a streaming body, but currently it only supports HTTP/2 trailers (there hasn't been much demand for HTTP/1.1 trailers). So there's two steps here:

  1. Expose hyper_body_trailers() in the C API. We can track that in this issue.
  2. Add HTTP/1.1 trailers support. I've opened #2703 for that.
bagder commented 2 years ago

I would also like to see support added for sending trailers in HTTP chunked requests.

seanmonstar commented 2 years ago

Good point, I don't know why I say "client-side receiving" and "server-side sending". I've cleaned them up to just "receiving" and "sending".

Xuanwo commented 2 years ago

Let's me have a try.

nnethercote commented 1 year ago

The following curl tests fail due to hyper's lack of trailers support: 266, 1417, 1540, 1591, 1943.

seanmonstar commented 1 year ago

FWIW, I haven't seen much demand for HTTP/1.1 trailers from anything else. So priority of implementing this (at least myself) is pretty low. Would it work to just mark all those as known to not work?

nnethercote commented 1 year ago

FWIW, I haven't seen much demand for HTTP/1.1 trailers from anything else. So priority of implementing this (at least myself) is pretty low. Would it work to just mark all those as known to not work?

I don't know enough about this to comment. More of a question for @bagder and @bdaehlie.

bagder commented 1 year ago

In curl it is already documented as a feature that does not work with hyper. We have set of those. That list is unfortunate because it confuses users and we will need to make sure to distribute the knowledge of those limitations into the user documentation if they remain when we want to remove the experimental tag.