19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
|
# File 'lib/labmanager/net_http_driver.rb', line 19
def send_http_request(request)
url = request.url
unless url.kind_of? ::URI::Generic
url = ::URI.parse(url)
end
::URI::Generic.send(:public, :path_query) path = url.path_query
http_request = case request.http_method
when :get
Net::HTTP::Get.new(path)
when :post
Net::HTTP::Post.new(path)
when :put
Net::HTTP::Put.new(path)
when :delete
Net::HTTP::Delete.new(path)
else
raise "Unsupported request method #{request.http_method}"
end
http_client = Net::HTTP.new(url.host, url.port)
http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
http_client.open_timeout = Handsoap.timeout
http_client.read_timeout = Handsoap.timeout
http_client.use_ssl = true if url.scheme == 'https'
if request.username && request.password
http_request.basic_auth request.username, request.password
end
request..each do |k, values|
values.each do |v|
http_request.add_field(k, v)
end
end
http_request.body = request.body
http_response = http_client.start do |client|
client.request(http_request)
end
def http_response.
@header.inject({}) do |h, (k, v)|
h[k.downcase] = v
h
end
end
if http_response.code == 401 && http_response.['www-authenticate']
auth_type = http_response.['www-authenticate'].chomp.match(/\w+/)[0].downcase
if auth_type != "basic"
raise "Authentication type #{auth_type} is unsupported by net/http"
end
end
parse_http_part(http_response., http_response.body, http_response.code)
end
|