Skip to content

Support for HTTP/1.1 chunked trailers#356

Description

@the-mikedavis

Hey hey! 馃憢

Poking around the gun functions I don't think it's currently possible to send HTTP/1.1 trailing headers (RFC7230 s. 4.1.2) when using chunked transfer-encoding.

Like one of the examples in the RFC, I'd like to use a trailing header for message integrity while uploading a file to S3 (docs). So I would read a chunks of a file from disk and stream on the connection while building a CRC32 or MD5, and then send that checksum as a trailer.

For other prior art I know that you can send trailers with Mint.HTTP.stream_request_body/3 which is conceptually very similar to gun:data/3. Maybe a nice way to handle this in the gun:data/3 interface could be to allow sending trailers with fin like Mint's {:eof, headers()} form.

-spec data(ConnPid, StreamRef, IsFin, Data) -> ok when
    ConnPid :: pid(),
    StreamRef :: gun:stream_ref(),
    IsFin :: fin | {fin, gun:req_headers()} | nofin,
    Data :: iodata().

Then you could stream the final chunk of the request body and the trailers in the same call to data/3.

What do you think - would you be interested in a PR for this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions