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)
-
- (Addressable::URI) request_uri
The Request-URI of the Request.
-
- ('http', 'https') scheme
The scheme of the Request.
Attributes included from GenericMessage
#entity_body, #headers, #http_version
Instance Method Summary (collapse)
-
- (Request) initialize(request_array, options = {})
constructor
Creates a new Request.
-
- (Method) method(*args)
The Method of the Request.
-
- method=(new_method)
Sets the Method of the Request.
-
- (String) request_line
(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
- (Request) initialize(request_array, options = {})
Creates a new Request
The attributes of the Request are passed in as an array. In order, they go:
- Method
- Request-URI
- Headers
- Entity Body
The method converts the values passed in to their proper types.
50 51 52 53 54 55 56 57 |
# File 'lib/webbed/request.rb', line 50 def initialize(request_array, = {}) self.method = request_array[0] self.request_uri = request_array[1] self.headers = request_array[2] self.entity_body = request_array[3] self.http_version = .delete(:http_version) || 1.1 self.scheme = .delete(:scheme) || 'http' end |
Instance Attribute Details
- (Addressable::URI) request_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 |
- ('http', 'https') scheme
The scheme of the Request
27 28 29 |
# File 'lib/webbed/request.rb', line 27 def scheme @scheme end |
Instance Method Details
- (Method) method(*args)
The Method of the Request
62 63 64 65 |
# File 'lib/webbed/request.rb', line 62 def method(*args) return super(*args) unless args.empty? @method end |
- method=(new_method)
Sets the Method of the Request
70 71 72 |
# File 'lib/webbed/request.rb', line 70 def method=(new_method) @method = Webbed::Method.new(new_method) end |
- (String) request_line Also known as: start_line
The Request-Line of the Request as defined in RFC 2616
81 82 83 |
# File 'lib/webbed/request.rb', line 81 def request_line "#{method} #{request_uri} #{http_version}\r\n" end |