Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (32 sloc) 1.057 kb
7ed819a Christian Neukirchen Add Rack::Response and Rack::Utils
chneukirchen authored
1 require 'rack/utils'
2
5f13e3d Christian Neukirchen Add Rack::Request
chneukirchen authored
3 module Rack
4 class Request
5 def initialize(env)
6 @env = env
7 end
8
9 def body; @env["rack.input"] end
10 def scheme; @env["rack.url_scheme"] end
11 def method; @env["REQUEST_METHOD"] end
12 def script_name; @env["SCRIPT_NAME"].to_s end
13 def path_info; @env["PATH_INFO"].to_s end
14 def host; @env["HTTP_HOST"] || @env["SERVER_NAME"] end
15 def path_info; @env["PATH_INFO"].to_s end
16 def port; @env["SERVER_PORT"].to_i end
17
18 def GET
7ed819a Christian Neukirchen Add Rack::Response and Rack::Utils
chneukirchen authored
19 Utils.parse_query(@env["QUERY_STRING"])
5f13e3d Christian Neukirchen Add Rack::Request
chneukirchen authored
20 end
21
22 def POST
23 @env["rack.request.formvars"] ||= body.read
7ed819a Christian Neukirchen Add Rack::Response and Rack::Utils
chneukirchen authored
24 Utils.parse_query(@env["rack.request.formvars"])
5f13e3d Christian Neukirchen Add Rack::Request
chneukirchen authored
25 end
26
27 def params
28 self.GET.update(self.POST)
29 end
30
31 def cookies
7ed819a Christian Neukirchen Add Rack::Response and Rack::Utils
chneukirchen authored
32 Utils.parse_query(@env["HTTP_COOKIE"], ';,') # XXX sure?
5f13e3d Christian Neukirchen Add Rack::Request
chneukirchen authored
33 end
34
35 def xhr?
36 @env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
37 end
38 end
39 end
Something went wrong with that request. Please try again.