diff options
author | Loïc Hoguin <[email protected]> | 2017-11-15 14:32:51 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-11-15 14:32:51 +0100 |
commit | 7728c624028db160edad2646f34d069d16af0869 (patch) | |
tree | 86f07ee306b8d6fc6396311fa83481638c537995 /src/cow_http.erl | |
parent | c510f28cc0526899a6c6d8a6e9cdbdca432ff490 (diff) | |
download | cowlib-7728c624028db160edad2646f34d069d16af0869.tar.gz cowlib-7728c624028db160edad2646f34d069d16af0869.tar.bz2 cowlib-7728c624028db160edad2646f34d069d16af0869.zip |
Add support for chunked transfer-encoding trailers
It considers all 0-sized chunks that aren't \r\n\r\n
to be trailers. There's no option for enabling/disabling
the behavior (for example when the te header was sent).
It doesn't parse the trailer, it's up to the user to
parse it separately via the new cow_http:headers/1 functions.
Note that this reuses the TotalLength part of the returned
'done' tuple to signal whether there are trailers. This value
has been ignored in Cowboy since 2.0 and was just a historical
leftover. I'm not aware of anyone using this module outside of
Gun or Cowboy, so I don't expect this to break anything. If it
does, well, it's not a documented function anyway. Your fault.
Diffstat (limited to 'src/cow_http.erl')
-rw-r--r-- | src/cow_http.erl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cow_http.erl b/src/cow_http.erl index de079ea..85b5d7a 100644 --- a/src/cow_http.erl +++ b/src/cow_http.erl @@ -23,6 +23,7 @@ -export([request/4]). -export([response/3]). +-export([headers/1]). -export([version/1]). -type version() :: 'HTTP/1.0' | 'HTTP/1.1'. @@ -254,8 +255,11 @@ request(Method, Path, Version, Headers) -> -spec response(status() | binary(), version(), headers()) -> iodata(). response(Status, Version, Headers) -> [version(Version), <<" ">>, status(Status), <<"\r\n">>, - [[N, <<": ">>, V, <<"\r\n">>] || {N, V} <- Headers], - <<"\r\n">>]. + headers(Headers), <<"\r\n">>]. + +-spec headers(headers()) -> iodata(). +headers(Headers) -> + [[N, <<": ">>, V, <<"\r\n">>] || {N, V} <- Headers]. %% @doc Return the version as a binary. |