pincers 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pincers/http/request.rb +13 -3
- data/lib/pincers/http/session.rb +9 -4
- data/lib/pincers/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4526e8ccc6d3ead10746ee9d7e95e473d063c467
|
4
|
+
data.tar.gz: 70fc43f5a6664ccbef9b0235db56e22065472882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ed5d778279256c922d66d71f763849edfc99f7060d818365a7ea73ffae06c5e3f7adf724d77021a05babd234f611e54c3898b657128f97a2ba81012acfc40f8
|
7
|
+
data.tar.gz: a911e5c4a3cb633f16308e6c03b4b27501f5241a0d2a1261a04e2f8d1e7acbb9df7e716f7aa2401874695a2c10032e334350c98e613b8bd70c5a2f01f8236394
|
data/lib/pincers/http/request.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Pincers::Http
|
2
2
|
class Request
|
3
3
|
|
4
|
-
|
5
|
-
attr_accessor :data
|
4
|
+
attr_accessor :method, :uri, :data, :headers
|
6
5
|
|
7
6
|
def initialize(_method, _uri)
|
8
7
|
@method = _method
|
@@ -51,6 +50,17 @@ module Pincers::Http
|
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
53
|
+
def clone_for_redirect(_location, _repeat = true)
|
54
|
+
clone = self.class.new(_repeat ? method : :get, _location)
|
55
|
+
|
56
|
+
if _repeat
|
57
|
+
clone.headers = clone.headers.clone
|
58
|
+
clone.data = data
|
59
|
+
end
|
60
|
+
|
61
|
+
clone
|
62
|
+
end
|
63
|
+
|
54
64
|
private
|
55
65
|
|
56
66
|
def default_encoding_for(_pairs)
|
@@ -59,4 +69,4 @@ module Pincers::Http
|
|
59
69
|
end
|
60
70
|
|
61
71
|
end
|
62
|
-
end
|
72
|
+
end
|
data/lib/pincers/http/session.rb
CHANGED
@@ -45,15 +45,15 @@ module Pincers::Http
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def perform(_request)
|
48
|
-
perform_recursive _request, @redirect_limit
|
48
|
+
perform_recursive _request, @redirect_limit
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
def perform_recursive(_request, _limit
|
53
|
+
def perform_recursive(_request, _limit)
|
54
54
|
raise MaximumRedirectsError.new if _limit == 0
|
55
55
|
|
56
|
-
uri =
|
56
|
+
uri = _request.uri
|
57
57
|
path = uri.request_uri.empty? ? '/' : uri.request_uri
|
58
58
|
|
59
59
|
http_request = _request.native_type.new path
|
@@ -72,12 +72,17 @@ module Pincers::Http
|
|
72
72
|
when Net::HTTPRedirection
|
73
73
|
location = Utils.parse_uri(http_response['location'])
|
74
74
|
location = URI.join(uri, location) if location.relative?
|
75
|
-
|
75
|
+
new_request = _request.clone_for_redirect(location, repeating_redirect?(http_response))
|
76
|
+
perform_recursive(new_request, _limit - 1)
|
76
77
|
else
|
77
78
|
handle_error_response Response.new(uri, http_response)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
82
|
+
def repeating_redirect?(_req)
|
83
|
+
["307", "308"].include?(_req.code)
|
84
|
+
end
|
85
|
+
|
81
86
|
def connect(_uri)
|
82
87
|
conn = Net::HTTP.new _uri.host, _uri.port || 80, @proxy_addr, @proxy_port
|
83
88
|
conn.use_ssl = true if _uri.scheme == 'https'
|
data/lib/pincers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pincers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacio Baixas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -288,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
288
288
|
version: '0'
|
289
289
|
requirements: []
|
290
290
|
rubyforge_project:
|
291
|
-
rubygems_version: 2.
|
291
|
+
rubygems_version: 2.6.1
|
292
292
|
signing_key:
|
293
293
|
specification_version: 4
|
294
294
|
summary: Web automation framework with multiple backend support
|