Class: Translatomatic::HTTP::Request
- Inherits:
-
Object
- Object
- Translatomatic::HTTP::Request
- Defined in:
- lib/translatomatic/http/request.rb
Overview
HTTP request wrapper for Net::HTTP functionality
Instance Attribute Summary collapse
-
#body ⇒ String
The HTTP body.
-
#method ⇒ String
readonly
The HTTP method.
-
#multipart_boundary ⇒ String
The text to use to denote multipart boundaries.
-
#uri ⇒ URI
readonly
The URI of the request.
Instance Method Summary collapse
-
#http_request ⇒ Object
The request object for use with Net::HTTP.
-
#initialize(method, url, options = {}) ⇒ Translatomatic::HTTPRequest
constructor
Create a new request.
Constructor Details
#initialize(method, url, options = {}) ⇒ Translatomatic::HTTPRequest
Returns Create a new request.
25 26 27 28 29 30 31 32 33 |
# File 'lib/translatomatic/http/request.rb', line 25 def initialize(method, url, = {}) @method = method @options = @uri = url.respond_to?(:host) ? url.dup : URI.parse(url) query = [:query] @uri.query = URI.encode_www_form(query) if query @multipart_boundary = generate_multipart_boundary @body = @options[:body] end |
Instance Attribute Details
#body ⇒ String
Returns the HTTP body.
14 15 16 |
# File 'lib/translatomatic/http/request.rb', line 14 def body @body end |
#method ⇒ String (readonly)
Returns the HTTP method.
20 21 22 |
# File 'lib/translatomatic/http/request.rb', line 20 def method @method end |
#multipart_boundary ⇒ String
Returns the text to use to denote multipart boundaries. By default, a random hexadecimal string is used.
11 12 13 |
# File 'lib/translatomatic/http/request.rb', line 11 def multipart_boundary @multipart_boundary end |
#uri ⇒ URI (readonly)
Returns the URI of the request.
17 18 19 |
# File 'lib/translatomatic/http/request.rb', line 17 def uri @uri end |
Instance Method Details
#http_request ⇒ Object
Returns The request object for use with Net::HTTP.
36 37 38 |
# File 'lib/translatomatic/http/request.rb', line 36 def http_request @request ||= create_request end |