webtester 0.2.0 → 0.2.1
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 +27 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4036ca95e2545491eacb48d4b40cb7568a5beaa6
|
4
|
+
data.tar.gz: 69d5486c71465bbb9c254fbecdd2882d3fc15751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdf2c606e4ab77faa22387be896ea42f07e66cab71dd3c1e8597b0a6b8432fdda637a6a7a5a310ecb092532aff9100d676f9f21aa2638cffba237d0434e2d8b2
|
7
|
+
data.tar.gz: 9cbbd6e86d668ef29d14e06e08c2896b6d96a9cb8652bedc25e8862fc26d39df8316d3ea59ae480a130d071acd7ddde56f7e18bbd930d538ae85979ae79e513e
|
data/lib/request.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'net/https'
|
2
3
|
require 'resolv'
|
3
4
|
require 'uri'
|
4
5
|
|
@@ -8,6 +9,7 @@ require 'cookie'
|
|
8
9
|
module WT
|
9
10
|
class Request
|
10
11
|
|
12
|
+
attr_accessor :request_protocol
|
11
13
|
attr_accessor :request_type
|
12
14
|
attr_accessor :request_url
|
13
15
|
attr_accessor :request_data
|
@@ -44,16 +46,22 @@ module WT
|
|
44
46
|
def get
|
45
47
|
url = URI.parse @request_url
|
46
48
|
url.path = '/' unless url.path.length > 0
|
49
|
+
|
47
50
|
req = Net::HTTP::Get.new(url.to_s)
|
48
51
|
|
52
|
+
self.request_protocol = url.scheme.downcase
|
53
|
+
|
49
54
|
return self.send url.host, url.port, req
|
50
55
|
end
|
51
56
|
|
52
57
|
def post
|
53
58
|
url = URI.parse @request_url
|
54
59
|
url.path = '/' unless url.path.length > 0
|
60
|
+
|
55
61
|
req = Net::HTTP::Post.new(url.to_s)
|
56
62
|
|
63
|
+
self.request_protocol = url.scheme.downcase
|
64
|
+
|
57
65
|
return send url.host, url.port, req
|
58
66
|
end
|
59
67
|
|
@@ -86,11 +94,7 @@ module WT
|
|
86
94
|
req[k] = v.to_s
|
87
95
|
end
|
88
96
|
|
89
|
-
|
90
|
-
req.body = @request_data
|
91
|
-
else
|
92
|
-
req.body = URI.encode_www_form @request_data if @request_data.length > 0
|
93
|
-
end
|
97
|
+
req.body = request_body
|
94
98
|
|
95
99
|
http = nil
|
96
100
|
|
@@ -102,6 +106,11 @@ module WT
|
|
102
106
|
http = Net::HTTP.new(host_ip, port)
|
103
107
|
end
|
104
108
|
|
109
|
+
if self.request_protocol == 'https'
|
110
|
+
http.use_ssl = true
|
111
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE;
|
112
|
+
end
|
113
|
+
|
105
114
|
WT::Log.debug("\t* http.request(request)")
|
106
115
|
response = http.request(req)
|
107
116
|
|
@@ -126,9 +135,21 @@ module WT
|
|
126
135
|
s += "#{k}: #{v}\r\n"
|
127
136
|
end
|
128
137
|
s += "\r\n"
|
129
|
-
s += self.
|
138
|
+
s += self.request_body
|
130
139
|
s
|
131
140
|
end
|
141
|
+
|
142
|
+
def request_body
|
143
|
+
body = ""
|
144
|
+
|
145
|
+
if @request_data and @request_data.is_a?(String)
|
146
|
+
body = @request_data
|
147
|
+
elsif @request_data.length > 0
|
148
|
+
body = URI.encode_www_form(@request_data)
|
149
|
+
end
|
150
|
+
|
151
|
+
return body
|
152
|
+
end
|
132
153
|
end
|
133
154
|
|
134
155
|
class NetworkIssueException < Exception
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webtester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego F. Nascimento
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " A simple API to create HTTP Request tests. "
|
14
14
|
email: diego.fnascimento@gmail.com
|