aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-09-16 01:55:40 +0200
committerLoïc Hoguin <[email protected]>2012-09-16 03:50:56 +0200
commite13ab806eaadd40c72145b5783c7727f2ed88d14 (patch)
tree83c06e5f4b3c32c9cb971e8145f0555417ce38d3 /src/cowboy_req.erl
parent527477bd4ac431f3810c3cec6679824112cf3612 (diff)
downloadcowboy-e13ab806eaadd40c72145b5783c7727f2ed88d14.tar.gz
cowboy-e13ab806eaadd40c72145b5783c7727f2ed88d14.tar.bz2
cowboy-e13ab806eaadd40c72145b5783c7727f2ed88d14.zip
Add cowboy_req:delete_resp_header/2
Both requested and better for making Req opaque.
Diffstat (limited to 'src/cowboy_req.erl')
-rw-r--r--src/cowboy_req.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 699c392..07acbe5 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -71,6 +71,7 @@
-export([set_resp_body_fun/3]).
-export([has_resp_header/2]).
-export([has_resp_body/1]).
+-export([delete_resp_header/2]).
-export([reply/2]).
-export([reply/3]).
-export([reply/4]).
@@ -724,7 +725,6 @@ set_resp_header(Name, Value, Req=#http_req{resp_headers=RespHeaders}) ->
set_resp_body(Body, Req) ->
{ok, Req#http_req{resp_body=Body}}.
-
%% @doc Add a body function to the response.
%%
%% The response body may also be set to a content-length - stream-function pair.
@@ -757,6 +757,13 @@ has_resp_body(#http_req{resp_body={Length, _}}) ->
has_resp_body(#http_req{resp_body=RespBody}) ->
iolist_size(RespBody) > 0.
+%% Remove a header previously set for the response.
+-spec delete_resp_header(cowboy_http:header(), Req)
+ -> Req when Req::req().
+delete_resp_header(Name, Req=#http_req{resp_headers=RespHeaders}) ->
+ RespHeaders2 = lists:keydelete(Name, 1, RespHeaders),
+ Req#http_req{resp_headers=RespHeaders2}.
+
%% @equiv reply(Status, [], [], Req)
-spec reply(cowboy_http:status(), Req) -> {ok, Req} when Req::req().
reply(Status, Req=#http_req{resp_body=Body}) ->