0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

update type of resp_body to iodata

resp_body is set by cowboy_http_req:set_resp_body/2 which accepts
the input type iodata(). Update the resp_body field to use the same
type. Also update the cowboy_http_req:has_resp_body/2 function to
use the iolist_size/1 which works with both binary() and iolist()
values instead of the byte_size/1 function which only works with
binary() values.
This commit is contained in:
Magnus Klaar 2011-12-16 16:19:08 +01:00
parent 621411350a
commit fed1410b14
2 changed files with 2 additions and 2 deletions

View file

@ -68,7 +68,7 @@
%% Response.
resp_state = waiting :: locked | waiting | chunks | done,
resp_headers = [] :: http_headers(),
resp_body = <<>> :: binary(),
resp_body = <<>> :: iodata(),
%% Functions.
urldecode :: {fun((binary(), T) -> binary()), T}

View file

@ -416,7 +416,7 @@ has_resp_header(Name, #http_req{resp_headers=RespHeaders}) ->
%% @doc Return whether a body has been set for the response.
-spec has_resp_body(#http_req{}) -> boolean().
has_resp_body(#http_req{resp_body=RespBody}) ->
byte_size(RespBody) > 0.
iolist_size(RespBody) > 0.
%% @equiv reply(Status, [], [], Req)
-spec reply(http_status(), #http_req{}) -> {ok, #http_req{}}.