Class: Webbed::Request
- Inherits:
-
Object
- Object
- Webbed::Request
- Includes:
- GenericMessage, Helpers::EntityHeadersHelper, Helpers::MethodHelper, Helpers::RackRequestHelper, Helpers::RequestHeadersHelper, Helpers::RequestURIHelper, Helpers::SchemeHelper
- Defined in:
- lib/webbed/request.rb
Overview
Representation of an HTTP Request.
This class contains the absolute minimum for accessing the different parts of an HTTP Request. Helper modules provide far more functionality.
Instance Attribute Summary collapse
-
#request_uri ⇒ Addressable::URI
The Request-URI of the Request.
-
#scheme ⇒ 'http', 'https'
The scheme of the Request.
Attributes included from GenericMessage
#entity_body, #headers, #http_version
Instance Method Summary collapse
-
#initialize(method, request_uri, headers, entity_body, options = {}) ⇒ Request
constructor
Creates a new Request.
-
#method(*args) ⇒ Method
The Method of the Request.
-
#method=(method)
Sets the Method of the Request.
-
#request_line ⇒ String
(also: #start_line)
The Request-Line of the Request as defined in RFC 2616.
Methods included from Helpers::EntityHeadersHelper
#content_length, #content_length=, #content_location, #content_location=, #content_md5, #content_md5=, #content_type, #content_type=
Methods included from Helpers::RequestHeadersHelper
#from, #from=, #host, #host=, #max_forwards, #max_forwards=, #referer, #referer=
Methods included from Helpers::SchemeHelper
Methods included from Helpers::RackRequestHelper
Methods included from Helpers::RequestURIHelper
Methods included from Helpers::MethodHelper
#connect?, #delete?, #get?, #head?, #idempotent?, #options?, #patch?, #post?, #put?, #safe?, #trace?
Methods included from GenericMessage
Constructor Details
#initialize(method, request_uri, headers, entity_body, options = {}) ⇒ Request
Creates a new Request.
The method converts the values passed in to their proper types.
45 46 47 48 49 50 51 52 |
# File 'lib/webbed/request.rb', line 45 def initialize(method, request_uri, headers, entity_body, = {}) self.method = method self.request_uri = request_uri self.headers = headers self.entity_body = entity_body self.http_version = [:http_version] || 1.1 self.scheme = [:scheme] || 'http' end |
Instance Attribute Details
#request_uri ⇒ Addressable::URI
Helpers::RequestURIHelper aliases this method to #request_url
.
The Request-URI of the Request.
The method automatically converts the new value to an instance of
Addressable::URI
if it is not already one.
18 19 20 |
# File 'lib/webbed/request.rb', line 18 def request_uri @request_uri end |
#scheme ⇒ 'http', 'https'
The scheme of the Request.
27 28 29 |
# File 'lib/webbed/request.rb', line 27 def scheme @scheme end |
Instance Method Details
#method(*args) ⇒ Method
The Method of the Request.
57 58 59 60 |
# File 'lib/webbed/request.rb', line 57 def method(*args) return super(*args) unless args.empty? @method end |
#method=(method)
Sets the Method of the Request.
65 66 67 |
# File 'lib/webbed/request.rb', line 65 def method=(method) @method = Webbed::Method.new(method) end |
#request_line ⇒ String Also known as: start_line
The Request-Line of the Request as defined in RFC 2616.
76 77 78 |
# File 'lib/webbed/request.rb', line 76 def request_line "#{method} #{request_uri} #{http_version}\r\n" end |