Class: Bijou::HttpRequest
- Inherits:
-
Object
- Object
- Bijou::HttpRequest
- Defined in:
- lib/bijou/httprequest.rb
Overview
This class represents an incoming HTTP request, presenting a common interface to the Bijou component regardless of the server environment.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cookies ⇒ Object
readonly
A hash containing cookies sent by the client.
-
#form ⇒ Object
readonly
Returns a hash containing form data passed via the HTTP POST action.
-
#http_method ⇒ Object
readonly
A string representing the HTTP request method (e.g., GET, POST, or HEAD).
-
#params ⇒ Object
readonly
Returns a hash containing the combined values of the query string, post data, and cookies.
-
#query_string ⇒ Object
readonly
Returns a hash containing items passed via the HTTP query string.
-
#server_variables ⇒ Object
readonly
A hash containing standard CGI environment variables.
Instance Method Summary collapse
-
#get ⇒ Object
Returns a hash containing items passed via the HTTP query string.
-
#initialize ⇒ HttpRequest
constructor
A new instance of HttpRequest.
- #physical_path ⇒ Object
-
#post ⇒ Object
Returns a hash containing form data passed via the HTTP POST action.
- #referer ⇒ Object
-
#referrer ⇒ Object
TODO: These should be moved to CGI::Request.
- #request_method ⇒ Object
- #user_agent ⇒ Object
-
#virtual_path ⇒ Object
++.
Constructor Details
#initialize ⇒ HttpRequest
Returns a new instance of HttpRequest.
14 15 16 17 18 19 20 21 |
# File 'lib/bijou/httprequest.rb', line 14 def initialize @params = {} @query_string = {} @form = {} @server_variables = {} @cookies = {} @http_method = '' end |
Instance Attribute Details
#cookies ⇒ Object (readonly)
A hash containing cookies sent by the client.
56 57 58 |
# File 'lib/bijou/httprequest.rb', line 56 def @cookies end |
#form ⇒ Object (readonly)
Returns a hash containing form data passed via the HTTP POST action. Synonym for #post.
29 30 31 |
# File 'lib/bijou/httprequest.rb', line 29 def form @form end |
#http_method ⇒ Object (readonly)
A string representing the HTTP request method (e.g., GET, POST, or HEAD).
59 60 61 |
# File 'lib/bijou/httprequest.rb', line 59 def http_method @http_method end |
#params ⇒ Object (readonly)
Returns a hash containing the combined values of the query string, post data, and cookies.
33 34 35 |
# File 'lib/bijou/httprequest.rb', line 33 def params @params end |
#query_string ⇒ Object (readonly)
Returns a hash containing items passed via the HTTP query string. Synonym for #get.
25 26 27 |
# File 'lib/bijou/httprequest.rb', line 25 def query_string @query_string end |
#server_variables ⇒ Object (readonly)
A hash containing standard CGI environment variables.
AUTH_TYPE HTTP_HOST REMOTE_IDENT
CONTENT_LENGTH HTTP_NEGOTIATE REMOTE_USER
CONTENT_TYPE HTTP_PRAGMA REQUEST_METHOD
GATEWAY_INTERFACE HTTP_REFERER SCRIPT_NAME
HTTP_ACCEPT HTTP_USER_AGENT SERVER_NAME
HTTP_ACCEPT_CHARSET PATH_INFO SERVER_PORT
HTTP_ACCEPT_ENCODING PATH_TRANSLATED SERVER_PROTOCOL
HTTP_ACCEPT_LANGUAGE QUERY_STRING SERVER_SOFTWARE
HTTP_CACHE_CONTROL REMOTE_ADDR
HTTP_FROM REMOTE_HOST
As well as additions that aren’t present in cgi.rb.
REQUEST_URI
53 54 55 |
# File 'lib/bijou/httprequest.rb', line 53 def server_variables @server_variables end |
Instance Method Details
#get ⇒ Object
Returns a hash containing items passed via the HTTP query string. Synonym for #query_string.
63 64 65 |
# File 'lib/bijou/httprequest.rb', line 63 def get @query_string end |
#physical_path ⇒ Object
96 97 98 |
# File 'lib/bijou/httprequest.rb', line 96 def physical_path @server_variables['PATH_TRANSLATED'] end |
#post ⇒ Object
Returns a hash containing form data passed via the HTTP POST action. Synonym for #form.
69 70 71 |
# File 'lib/bijou/httprequest.rb', line 69 def post @form end |
#referer ⇒ Object
78 79 80 |
# File 'lib/bijou/httprequest.rb', line 78 def referer @server_variables['HTTP_REFERER'] end |
#referrer ⇒ Object
TODO: These should be moved to CGI::Request
74 75 76 |
# File 'lib/bijou/httprequest.rb', line 74 def referrer @server_variables['HTTP_REFERER'] end |
#request_method ⇒ Object
100 101 102 |
# File 'lib/bijou/httprequest.rb', line 100 def request_method @server_variables['REQUEST_METHOD'] end |
#user_agent ⇒ Object
104 105 106 |
# File 'lib/bijou/httprequest.rb', line 104 def user_agent @server_variables['HTTP_USER_AGENT'] end |
#virtual_path ⇒ Object
++
91 92 93 94 |
# File 'lib/bijou/httprequest.rb', line 91 def virtual_path # @server_variables['REQUEST_URI'] @server_variables['PATH_INFO'] end |