def execute(request, uri, parameters = {}, headers = {}, userconfig = nil)
{
'content-type' => 'application/x-www-form-urlencoded'
}.merge(headers).each { |k,v| request[k] = v }
http = agent_class.new( uri.host, uri.port )
if uri.scheme == 'https' && uri.host !~ /localhost/
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
request.basic_auth(userconfig["username"], userconfig["password"])
request_data = case request['Content-Type']
when /boundary=(.*)$/
boundary_data_for($1, parameters)
else
query_string_for(parameters)
end
request['Content-Length'] = request_data.length.to_s
response = http.request(request, request_data)
return response.body if response.class <= Net::HTTPSuccess
if response.class <= Net::HTTPRedirection
location = response['Location']
unless location =~ /^http/
location = "#{uri.scheme}://#{uri.host}#{location}"
end
uri = URI.parse(location)
execute(agent_class::Get.new(uri.request_uri), uri)
end
end