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(method, request_uri, headers, entity_body, options = {})
constructor
Creates a new Request.
-
- (Webbed::Method) method(*args)
The Method of the Request.
-
- method=(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
#allowed_methods, #allowed_methods=, #content_length, #content_length=, #content_location, #content_location=, #content_md5, #content_md5=, #content_type, #content_type=
Methods included from Helpers::RequestHeadersHelper
#accepted_charsets, #accepted_charsets=, #accepted_language_ranges, #accepted_language_ranges=, #accepted_media_ranges, #accepted_media_ranges=, #from, #from=, #host, #host=, #max_forwards, #max_forwards=, #negotiate_charset, #negotiate_language_tag, #negotiate_media_type, #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(method, request_uri, headers, entity_body, options = {})
Creates a new Request.
The method converts the values passed in to their proper types.
43 44 45 46 47 48 49 50 |
# File 'lib/webbed/request.rb', line 43 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 = .fetch(:http_version, 1.1) self.scheme = .fetch(: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
- (Webbed::Method) method(*args)
The Method of the Request.
55 56 57 58 |
# File 'lib/webbed/request.rb', line 55 def method(*args) return super(*args) unless args.empty? @method end |
- method=(method)
Sets the Method of the Request.
63 64 65 |
# File 'lib/webbed/request.rb', line 63 def method=(method) @method = Webbed::Method.lookup(method) end |
- (String) request_line Also known as: start_line
The Request-Line of the Request as defined in RFC 2616.
74 75 76 |
# File 'lib/webbed/request.rb', line 74 def request_line "#{method} #{request_uri} #{http_version}\r\n" end |