Created
June 10, 2009 21:39
-
-
Save tammersaleh/127518 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def cookies | |
| return {} unless @env["HTTP_COOKIE"] | |
| if @env["rack.request.cookie_string"] == @env["HTTP_COOKIE"] | |
| @env["rack.request.cookie_hash"] | |
| else | |
| @env["rack.request.cookie_string"] = @env["HTTP_COOKIE"] | |
| # According to RFC 2109: | |
| # If multiple cookies satisfy the criteria above, they are ordered in | |
| # the Cookie header such that those with more specific Path attributes | |
| # precede those with less specific. Ordering with respect to other | |
| # attributes (e.g., Domain) is unspecified. | |
| @env["rack.request.cookie_hash"] = | |
| Utils.parse_query(@env["rack.request.cookie_string"], ';,').inject({}) {|h,(k,v)| | |
| h[k] = Array === v ? v.first : v | |
| h | |
| } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment