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(payload, headers) ⇒ Object
- #split(*arguments) ⇒ Object
Methods inherited from Generic
#process_response, #wrap_response
Constructor Details
#initialize(content_type = APPLICATION_FORM_URLENCODED) ⇒ URLEncoded
Returns a new instance of URLEncoded.
36 37 38 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 36 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.
40 41 42 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 40 def content_type @content_type end |
Instance Method Details
#parser_for(response) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 64 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(payload, headers) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 46 def prepare_request(payload, headers) headers['accept'] ||= @content_type if payload headers['content-type'] = @content_type ::Protocol::HTTP::Body::Buffered.new([ ::Protocol::HTTP::URL.encode(payload) ]) end end |
#split(*arguments) ⇒ Object
42 43 44 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 42 def split(*arguments) @content_type.split end |