Class: Async::REST::Wrapper::URLEncoded
- Defined in:
- lib/async/rest/wrapper/url_encoded.rb
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- APPLICATION_FORM_URLENCODED =
"application/x-www-form-urlencoded".freeze
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
-
#initialize(content_type = APPLICATION_FORM_URLENCODED) ⇒ URLEncoded
constructor
A new instance of URLEncoded.
- #parser_for(response) ⇒ Object
- #prepare_request(request, payload) ⇒ Object
- #split(*arguments) ⇒ Object
Methods inherited from Generic
#call, #process_response, #response_for, #retry_after_duration, #wrap_response
Constructor Details
#initialize(content_type = APPLICATION_FORM_URLENCODED) ⇒ URLEncoded
Returns a new instance of URLEncoded.
19 20 21 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 19 def initialize(content_type = APPLICATION_FORM_URLENCODED) @content_type = content_type end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
23 24 25 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 23 def content_type @content_type end |
Instance Method Details
#parser_for(response) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 47 def parser_for(response) if content_type = response.headers["content-type"] if content_type.start_with? @content_type return Parser end end return super end |
#prepare_request(request, payload) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 29 def prepare_request(request, payload) request.headers["accept"] ||= @content_type if payload request.headers["content-type"] = @content_type request.body = ::Protocol::HTTP::Body::Buffered.new([ ::Protocol::URL::Encoding.encode(payload) ]) end end |
#split(*arguments) ⇒ Object
25 26 27 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 25 def split(*arguments) @content_type.split end |