From cbbb4d5523f8738b237593f9516c3a237d0cc2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 15 Nov 2017 14:39:36 +0100 Subject: Add preliminary support for trailers The code is definitely not the best, but as long as it doesn't break anything it should be OK for now. --- src/gun.erl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gun.erl') diff --git a/src/gun.erl b/src/gun.erl index 311e405..e6ed183 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -359,6 +359,8 @@ await(ServerPid, StreamRef, Timeout, MRef) -> {response, IsFin, Status, Headers}; {gun_data, ServerPid, StreamRef, IsFin, Data} -> {data, IsFin, Data}; + {gun_trailers, ServerPid, StreamRef, Trailers} -> + {trailers, Trailers}; {gun_push, ServerPid, StreamRef, NewStreamRef, Method, URI, Headers} -> {push, NewStreamRef, Method, URI, Headers}; {gun_error, ServerPid, StreamRef, Reason} -> @@ -395,6 +397,10 @@ await_body(ServerPid, StreamRef, Timeout, MRef, Acc) -> << Acc/binary, Data/binary >>); {gun_data, ServerPid, StreamRef, fin, Data} -> {ok, << Acc/binary, Data/binary >>}; + %% It's OK to return trailers here because the client + %% specifically requested them. + {gun_trailers, ServerPid, StreamRef, Trailers} -> + {ok, Acc, Trailers}; {gun_error, ServerPid, StreamRef, Reason} -> {error, Reason}; {gun_error, ServerPid, Reason} -> -- cgit v1.2.3