-
-
Notifications
You must be signed in to change notification settings - Fork 237
Description
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?