Class: RestClient::Payload::UrlEncoded
- Defined in:
- lib/restclient/payload.rb
Instance Method Summary collapse
- #build_stream(params = nil) ⇒ Object
-
#handle_key(key) ⇒ Object
for UrlEncoded escape the keys.
- #headers ⇒ Object
Methods inherited from Base
#close, #flatten_params, #flatten_params_array, #initialize, #inspect, #read, #short_inspect, #size
Constructor Details
This class inherits a constructor from RestClient::Payload::Base
Instance Method Details
#build_stream(params = nil) ⇒ Object
126 127 128 129 130 131 |
# File 'lib/restclient/payload.rb', line 126 def build_stream(params = nil) @stream = StringIO.new(flatten_params(params).collect do |entry| "#{entry[0]}=#{handle_key(entry[1])}" end.join("&")) @stream.seek(0) end |
#handle_key(key) ⇒ Object
for UrlEncoded escape the keys
134 135 136 |
# File 'lib/restclient/payload.rb', line 134 def handle_key key URI.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) end |
#headers ⇒ Object
138 139 140 |
# File 'lib/restclient/payload.rb', line 138 def headers super.merge({'Content-Type' => 'application/x-www-form-urlencoded'}) end |