webtester 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/request.rb +23 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 429bb7365ea2e47cfb103859a61de99e9ec466ab
|
4
|
+
data.tar.gz: 1e66cd581083a9611809501d2b5c44e581b08679
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed434569b32dc128d04e0251853a3f42927d114c3b8e3f847de28e021551022fda8f967f4a8bd1fa0e5f14be5dcefa3491ff1b2344b04f132ba6f06903a994bf
|
7
|
+
data.tar.gz: c4e02a17fd98b33303a4994e503f9869d7ed70b36523e2cb10b56e731987bb5d1c02d3112137c21b6e801164985afa6804570bda935102607f452730e3e76903
|
data/lib/request.rb
CHANGED
@@ -46,8 +46,8 @@ module WT
|
|
46
46
|
def get
|
47
47
|
url = URI.parse @request_url
|
48
48
|
url.path = '/' unless url.path.length > 0
|
49
|
-
|
50
|
-
req = Net::HTTP::Get.new(url.
|
49
|
+
|
50
|
+
req = Net::HTTP::Get.new(url.path)
|
51
51
|
|
52
52
|
self.request_protocol = url.scheme.downcase
|
53
53
|
|
@@ -58,7 +58,7 @@ module WT
|
|
58
58
|
url = URI.parse @request_url
|
59
59
|
url.path = '/' unless url.path.length > 0
|
60
60
|
|
61
|
-
req = Net::HTTP::Post.new(url.
|
61
|
+
req = Net::HTTP::Post.new(url.path)
|
62
62
|
|
63
63
|
self.request_protocol = url.scheme.downcase
|
64
64
|
|
@@ -69,20 +69,12 @@ module WT
|
|
69
69
|
|
70
70
|
WT::Log.debug(">> WT::Request::send(host: #{host}, port: #{port})")
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
unless host.match(/^[0-9]{1,3}(\.[0-9]{1,3}){3}$/)
|
75
|
-
WT::Log.debug("\t* resolving #{host}...")
|
76
|
-
|
72
|
+
unless host.match(/^[0-9]{1,3}(\.[0-9]{1,3}){3}$/) or self.proxy_host
|
77
73
|
begin
|
78
|
-
|
74
|
+
Resolv::DNS.new().getaddress(host).to_s
|
79
75
|
rescue Resolv::ResolvError => re
|
80
76
|
raise DNSResolvErrorException.new(host)
|
81
77
|
end
|
82
|
-
|
83
|
-
WT::Log.debug("\t\t* success: #{host_ip}")
|
84
|
-
else
|
85
|
-
WT::Log.debug("\t * no need to resolv. Already in IP format.")
|
86
78
|
end
|
87
79
|
|
88
80
|
ret = nil
|
@@ -96,29 +88,34 @@ module WT
|
|
96
88
|
|
97
89
|
req.body = request_body
|
98
90
|
|
99
|
-
|
91
|
+
response = nil
|
92
|
+
ssl = (self.request_protocol == 'https')
|
93
|
+
options = if ssl
|
94
|
+
{ :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE }
|
95
|
+
else
|
96
|
+
{}
|
97
|
+
end
|
100
98
|
|
101
99
|
if self.proxy_host
|
102
100
|
WT::Log.debug("\t* @proxy_host = #{self.proxy_host}, proxy_port = #{self.proxy_port}")
|
103
|
-
|
101
|
+
Net::HTTP::Proxy(self.proxy_host, self.proxy_port).start(host, port, options) do |http|
|
102
|
+
WT::Log.debug("\t* http.request(#{host})")
|
103
|
+
response = http.request(req)
|
104
|
+
end
|
104
105
|
else
|
105
|
-
WT::Log.debug("\t* Net::HTTP.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
http.use_ssl = true
|
111
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE;
|
106
|
+
WT::Log.debug("\t* Net::HTTP.start(#{host}, #{port})")
|
107
|
+
Net::HTTP.start(host, port, options) do |http|
|
108
|
+
WT::Log.debug("\t* http.request(#{host})")
|
109
|
+
response = http.request(req)
|
110
|
+
end
|
112
111
|
end
|
113
112
|
|
114
|
-
|
115
|
-
response = http.request(req)
|
116
|
-
|
117
|
-
raise "Could not connect to host: #{host_ip}:#{port}" unless response
|
113
|
+
raise "Could not connect to host: #{host}:#{port}" unless response
|
118
114
|
|
119
115
|
ret = WT::Result.new(self, response)
|
120
116
|
|
121
117
|
WT::Log.debug("\t* WT::Result.new(self, response): #{response.code}")
|
118
|
+
|
122
119
|
rescue Exception => e
|
123
120
|
WT::Log.error("\t* Exception: #{e.message}")
|
124
121
|
ret = WT::Result.new self, nil
|