Просмотр исходного кода

Fix specs to allow headers as iodata() and not just binary()

Loïc Hoguin 13 лет назад
Родитель
Сommit
99d8f837fe
2 измененных файлов с 3 добавлено и 3 удалено
  1. 1 1
      include/http.hrl
  2. 2 2
      src/cowboy_http_req.erl

+ 1 - 1
include/http.hrl

@@ -33,7 +33,7 @@
 	| 'Expires' | 'Last-Modified' | 'Accept-Ranges' | 'Set-Cookie'
 	| 'Expires' | 'Last-Modified' | 'Accept-Ranges' | 'Set-Cookie'
 	| 'Set-Cookie2' | 'X-Forwarded-For' | 'Cookie' | 'Keep-Alive'
 	| 'Set-Cookie2' | 'X-Forwarded-For' | 'Cookie' | 'Keep-Alive'
 	| 'Proxy-Connection' | binary().
 	| 'Proxy-Connection' | binary().
--type http_headers() :: list({http_header(), binary()}).
+-type http_headers() :: list({http_header(), iodata()}).
 -type http_cookies() :: list({binary(), binary()}).
 -type http_cookies() :: list({binary(), binary()}).
 -type http_status() :: non_neg_integer() | binary().
 -type http_status() :: non_neg_integer() | binary().
 
 

+ 2 - 2
src/cowboy_http_req.erl

@@ -363,7 +363,7 @@ body_qs(Req) ->
 %% Response API.
 %% Response API.
 
 
 %% @doc Add a header to the response.
 %% @doc Add a header to the response.
--spec set_resp_header(http_header(), binary(), #http_req{})
+-spec set_resp_header(http_header(), iodata(), #http_req{})
 	-> {ok, #http_req{}}.
 	-> {ok, #http_req{}}.
 set_resp_header(Name, Value, Req=#http_req{resp_headers=RespHeaders}) ->
 set_resp_header(Name, Value, Req=#http_req{resp_headers=RespHeaders}) ->
 	NameBin = header_to_binary(Name),
 	NameBin = header_to_binary(Name),
@@ -373,7 +373,7 @@ set_resp_header(Name, Value, Req=#http_req{resp_headers=RespHeaders}) ->
 %%
 %%
 %% The body set here is ignored if the response is later sent using
 %% The body set here is ignored if the response is later sent using
 %% anything other than reply/2 or reply/3.
 %% anything other than reply/2 or reply/3.
--spec set_resp_body(binary(), #http_req{}) -> {ok, #http_req{}}.
+-spec set_resp_body(iodata(), #http_req{}) -> {ok, #http_req{}}.
 set_resp_body(Body, Req) ->
 set_resp_body(Body, Req) ->
 	{ok, Req#http_req{resp_body=Body}}.
 	{ok, Req#http_req{resp_body=Body}}.