55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/gems/rubyforge-1.0.1/lib/rubyforge/client.rb', line 55
def execute(request, uri, parameters = {}, = {})
{
'content-type' => 'application/x-www-form-urlencoded'
}.merge().each { |k,v| request[k] = v }
@cookie_manager[uri].each { |k,v|
request['Cookie'] = v.to_s
}
http = agent_class.new( uri.host, uri.port )
if uri.scheme == 'https'
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
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)
(response.get_fields('Set-Cookie') || []).each do |raw_cookie|
WEBrick::Cookie.parse_set_cookies(raw_cookie).each { |baked_cookie|
baked_cookie.domain ||= url.host
baked_cookie.path ||= url.path
@cookie_manager.add(uri, baked_cookie)
}
end
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
|