tsaleh (owner)

Revisions

gist: 127518 Download_button fork
public
Public Clone URL: git://gist.github.com/127518.git
request.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    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