From 849fab7227a2fd1ff5fa4d603ba89037e1c462b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 26 May 2020 09:54:54 +0200 Subject: Cowboy 2.8.0 --- .../manual/cowboy_req.filter_cookies/index.html | 200 +++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 docs/en/cowboy/2.8/manual/cowboy_req.filter_cookies/index.html (limited to 'docs/en/cowboy/2.8/manual/cowboy_req.filter_cookies') diff --git a/docs/en/cowboy/2.8/manual/cowboy_req.filter_cookies/index.html b/docs/en/cowboy/2.8/manual/cowboy_req.filter_cookies/index.html new file mode 100644 index 00000000..073b880c --- /dev/null +++ b/docs/en/cowboy/2.8/manual/cowboy_req.filter_cookies/index.html @@ -0,0 +1,200 @@ + + + + + + + + + + Nine Nines: cowboy_req:filter_cookies(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

cowboy_req:filter_cookies(3)

+ +

Name

+

cowboy_req:filter_cookies - Filter cookie headers

+

Description

+
+
filter_cookies(Names, Req) -> Req
+
+Names :: [atom() | binary()]
+
+

Filter cookie headers.

+

This function is meant to be used before attempting to parse or match cookies in order to remove cookies that are not relevant and are potentially malformed. Because Cowboy by default crashes on malformed cookies, this function allows processing requests that would otherwise result in a 400 error.

+

Malformed cookies are unfortunately fairly common due to the string-based interface provided by browsers and this function provides a middle ground between Cowboy's strict behavior and chaotic real world use cases.

+

Note that there may still be crashes even after filtering cookies because this function does not correct malformed values. Cookies that have malformed values should probably be unset in an error response or in a redirect.

+

This function can be called even if there are no cookies in the request.

+

Arguments

+
Names
+

The cookies that should be kept.

+
+
Req
+

The Req object.

+
+
+

Return value

+

The Req object is returned with its cookie header value filtered.

+

Changelog

+
  • 2.7: Function introduced. +
  • +
+

Examples

+
Filter then parse cookies
+
+
Req = cowboy_req:filter_cookies([session_id, token], Req0),
+Cookies = cowboy_req:parse_cookies(Req).
+
+

See also

+

cowboy_req(3), cowboy_req:parse_cookies(3), cowboy_req:match_cookies(3)

+ + + + + + +
+ +
+ + +

+ Cowboy + 2.8 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +

Like my work? Donate!

+

Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:

+
+ + + + + + + + + +

Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.

+ + + +
+
+
+
+ + + + + + + + + -- cgit v1.2.3