Class: XamarinTestCloud::HTTP::Payload::UrlEncoded

Inherits:
Base
  • Object
show all
Defined in:
lib/xamarin-test-cloud/http/payload.rb

Constant Summary collapse

Parser =
URI.const_defined?(:Parser) ? URI::Parser.new : URI
Escape =
Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")

Instance Method Summary collapse

Methods inherited from Base

#close, #flatten_params, #flatten_params_array, #initialize, #inspect, #read, #short_inspect, #size

Constructor Details

This class inherits a constructor from XamarinTestCloud::HTTP::Payload::Base

Instance Method Details

#build_stream(params = nil) ⇒ Object



169
170
171
172
173
174
# File 'lib/xamarin-test-cloud/http/payload.rb', line 169

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



177
178
179
# File 'lib/xamarin-test-cloud/http/payload.rb', line 177

def handle_key key
  Parser.escape(key.to_s, Escape)
end

#headersObject



181
182
183
# File 'lib/xamarin-test-cloud/http/payload.rb', line 181

def headers
  super.merge({'Content-Type' => 'application/x-www-form-urlencoded'})
end