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(*args) ⇒ Object
Methods inherited from Generic
#process_response, #wrap_response
Constructor Details
#initialize(content_type = APPLICATION_FORM_URLENCODED) ⇒ URLEncoded
Returns a new instance of URLEncoded.
34 35 36 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 34 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.
38 39 40 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 38 def content_type @content_type end |
Instance Method Details
#parser_for(response) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 62 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
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 44 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(*args) ⇒ Object
40 41 42 |
# File 'lib/async/rest/wrapper/url_encoded.rb', line 40 def split(*args) @content_type.split end |