micky 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/micky/request.rb +18 -0
- data/lib/micky/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: 69d2ab4b7b2dbf26fe03841cbfed112bd4d75eb0
|
4
|
+
data.tar.gz: c5849d98557ce9e9612ef490f197d326c5783e5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5080fda9b4c7c811e7aa78ea9360a25a6768d5c3e38c21751c5e6a78536f78cc413c42c4843aa8c97a3bbc1d412eed4337a74ad1362412c051b71cd74d692799
|
7
|
+
data.tar.gz: ac330e86b9bc28ae009e262596e2546d6830b9b221352e8c92181cd09f7889c369136ae98cab0b9348bafea487d9a43159dccc1d74f1a33402c0d724070aea2e
|
data/lib/micky/request.rb
CHANGED
@@ -34,7 +34,25 @@ module Micky
|
|
34
34
|
when Net::HTTPSuccess
|
35
35
|
Response.new(response)
|
36
36
|
when Net::HTTPRedirection
|
37
|
+
previous_uri = uri
|
37
38
|
uri = response['Location']
|
39
|
+
|
40
|
+
if uri !~ Micky::HTTP_URI_REGEX
|
41
|
+
if uri.start_with? '//'
|
42
|
+
# Protocol-relative
|
43
|
+
uri = Micky::URI(uri).to_s
|
44
|
+
elsif uri.start_with? '/'
|
45
|
+
# Host-relative
|
46
|
+
previous_uri = Micky::URI(previous_uri)
|
47
|
+
uri = File.join("#{previous_uri.scheme}://#{previous_uri.host}", uri)
|
48
|
+
else
|
49
|
+
# Path-relative
|
50
|
+
previous_uri = Micky::URI(previous_uri)
|
51
|
+
previous_directory = previous_uri.path.sub(/[^\/]+\z/, '')
|
52
|
+
uri = File.join("#{previous_uri.scheme}://#{previous_uri.host}#{previous_directory}", uri)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
38
56
|
log "Redirect to #{uri}"
|
39
57
|
request_with_redirect_handling(uri, redirect_count + 1)
|
40
58
|
else
|
data/lib/micky/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafaël Blais Masson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.4.5
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Lightweight and worry-free HTTP client
|