webtester 0.0.6 → 0.0.7
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 +11 -1
- data/lib/test.rb +8 -0
- 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: aaaff53873b7affd9e6922638b72b6b03c22c5c1
|
4
|
+
data.tar.gz: 2463767556fdecfe728e63a9201cb4621d67d943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f2965ca5213a7ce9e6ad068a73b71ac28bb931d4dcaabf285386ccd51d6bb1076e245af5889a389c5dd577e6de54578f14e264a3790b0f70eb4cd8c87aecf84
|
7
|
+
data.tar.gz: cbdb5b21de896652017a03b25af3cc676aafc60eed2d34dd17f6111e423903c8d5ba56d9a70ae1046791fcee354d70a6591566f602ab79389f023794b2a45ef6
|
data/lib/request.rb
CHANGED
@@ -12,6 +12,8 @@ module WT
|
|
12
12
|
attr_accessor :request_data
|
13
13
|
attr_accessor :follow_redirect
|
14
14
|
attr_accessor :headers
|
15
|
+
attr_accessor :proxy_host
|
16
|
+
attr_accessor :proxy_port
|
15
17
|
|
16
18
|
def initialize(request_type, request_url, request_data = {})
|
17
19
|
@request_type = request_type
|
@@ -19,6 +21,8 @@ module WT
|
|
19
21
|
@request_data = request_data
|
20
22
|
@follow_redirect = true
|
21
23
|
@headers = {}
|
24
|
+
@proxy_host = nil
|
25
|
+
@proxy_port = 0
|
22
26
|
end
|
23
27
|
|
24
28
|
def exec
|
@@ -48,7 +52,13 @@ module WT
|
|
48
52
|
req['Cookie'] = @headers['Cookie'].to_s if @headers['Cookie']
|
49
53
|
req.body = URI.encode_www_form @request_data if @request_data.length > 0
|
50
54
|
|
51
|
-
http =
|
55
|
+
http = nil
|
56
|
+
|
57
|
+
if @proxy_host
|
58
|
+
http = Net::HTTP::Proxy(@proxy_host, @proxy_port).new(host, port)
|
59
|
+
else
|
60
|
+
http = Net::HTTP.new(host, port)
|
61
|
+
end
|
52
62
|
|
53
63
|
response = http.request req
|
54
64
|
|
data/lib/test.rb
CHANGED
@@ -62,12 +62,16 @@ module WT
|
|
62
62
|
attr_accessor :requests
|
63
63
|
attr_accessor :cookies
|
64
64
|
attr_accessor :form_fields
|
65
|
+
attr_accessor :proxy_host
|
66
|
+
attr_accessor :proxy_port
|
65
67
|
|
66
68
|
def initialize(name)
|
67
69
|
@name = name
|
68
70
|
@requests = []
|
69
71
|
@cookies = []
|
70
72
|
@form_fields = {}
|
73
|
+
@proxy_host = nil
|
74
|
+
@proxy_port = 0
|
71
75
|
end
|
72
76
|
|
73
77
|
def add_request(request)
|
@@ -82,6 +86,10 @@ module WT
|
|
82
86
|
req.request_data[name].gsub! "$?", "#{value}" if req.request_data and req.request_data[name]
|
83
87
|
end
|
84
88
|
|
89
|
+
# set proxy if exists
|
90
|
+
req.proxy_host = @proxy_host
|
91
|
+
req.proxy_port = @proxy_port
|
92
|
+
|
85
93
|
result = req.exec
|
86
94
|
|
87
95
|
all_cookies = result.response['Set-Cookie']
|