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

Change the type of cookie name to binary()

The API will be more consistent like this, and we can ensure
that duplicate cookie names are never sent.
Loïc Hoguin 8 лет назад
Родитель
Сommit
87a05a1219
2 измененных файлов с 3 добавлено и 4 удалено
  1. 2 3
      doc/src/manual/cowboy_req.set_resp_cookie.asciidoc
  2. 1 1
      src/cowboy_req.erl

+ 2 - 3
doc/src/manual/cowboy_req.set_resp_cookie.asciidoc

@@ -14,13 +14,11 @@ set_resp_cookie(Name, Value, Req :: cowboy_req:req())
 set_resp_cookie(Name, Value, Opts, Req :: cowboy_req:req())
     -> Req
 
-Name  :: iodata()                  %% case sensitive
+Name  :: binary()                  %% case sensitive
 Value :: iodata()                  %% case sensitive
 Opts  :: cow_cookie:cookie_opts()
 ----
 
-// @todo I am not particularly happy about the fact that the name is iodata().
-
 Set a cookie to be sent with the response.
 
 Note that cookie names are case sensitive.
@@ -53,6 +51,7 @@ otherwise the cookie will not be sent in the response.
 == Changelog
 
 * *2.0*: `set_resp_cookie/3` introduced as an alias to `set_resp_cookie/4` with no options.
+* *2.0*: The first argument type is now `binary()` instead of `iodata()`.
 * *1.0*: Function introduced.
 
 == Examples

+ 1 - 1
src/cowboy_req.erl

@@ -556,7 +556,7 @@ set_resp_cookie(Name, Value, Req) ->
 %% The cookie value cannot contain any of the following characters:
 %%   ,; \t\r\n\013\014
 %% @todo Fix the cookie_opts() type.
--spec set_resp_cookie(iodata(), iodata(), cookie_opts(), Req)
+-spec set_resp_cookie(binary(), iodata(), cookie_opts(), Req)
 	-> Req when Req::req().
 set_resp_cookie(Name, Value, Opts, Req) ->
 	Cookie = cow_cookie:setcookie(Name, Value, maps:to_list(Opts)),