redirect_follow_get 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -14
- data/lib/redirect_follow_get.rb +3 -1
- data/lib/redirect_follow_get/version.rb +2 -1
- data/redirect_follow_get.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97c056312496571885d638b57f696c8dc8b7a26c
|
4
|
+
data.tar.gz: ce3792d988d3a3e60d7b4e644c15e66ff54ad4a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f84a8c3e58c4e6347dad6e078e34079e48b121e1ff77441f9e14bdfec1f2d6fb05840dca9c4d313ad092b3f7aa7514dadfc3fd40cbbbaf0118cb78ba0f00dbe
|
7
|
+
data.tar.gz: 052c5c1bf3ee2a68292fbcf3c643cb404c00585ccb693ade47f030cd135591c9ab2c705719f2e261fffc216cc1b4aef023ef31326099e8725dfa8590a85996cc
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# redirect_follow_get
|
2
2
|
|
3
|
-
`redirect_follow_get` is simple http get method
|
3
|
+
`redirect_follow_get` is simple http get method following redirect. It wraps `net/http` library.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,28 +20,25 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
`redirect_follow_get` returns `Net::HTTPOK` when the request gets 200 response.
|
24
24
|
|
25
25
|
```rb
|
26
26
|
response = redirect_follow_get('http://google.com/')
|
27
27
|
# => #<Net::HTTPOK 200 OK readbody=true>
|
28
|
+
```
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
puts response.uri
|
33
|
-
# http://www.google.co.jp/?gfe_rd=...
|
30
|
+
```rb
|
31
|
+
response.code
|
32
|
+
# => "200"
|
34
33
|
|
35
|
-
|
36
|
-
#
|
37
|
-
# <html>
|
38
|
-
# <head>
|
39
|
-
# <meta charset="utf-8">
|
40
|
-
# ...
|
34
|
+
response.uri
|
35
|
+
# => #<URI::HTTP http://www.google.co.jp/?gfe_rd=...>
|
41
36
|
|
37
|
+
response.body
|
38
|
+
# => "<!doctype html><html ...
|
42
39
|
```
|
43
40
|
|
44
|
-
###
|
41
|
+
### Redirection limit
|
45
42
|
|
46
43
|
You can limit the number of redirects with `limit:` option. **Default redirects limit is 10.**
|
47
44
|
|
data/lib/redirect_follow_get.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'redirect_follow_get/version'
|
2
3
|
require 'net/http'
|
3
4
|
|
@@ -8,7 +9,8 @@ end
|
|
8
9
|
def redirect_follow_get(url, limit: 10)
|
9
10
|
raise RedirectFollowGet::TooManyRedirects, 'too many HTTP redirects' if limit.zero?
|
10
11
|
|
11
|
-
|
12
|
+
uri = URI(URI.escape(url))
|
13
|
+
case response = Net::HTTP.get_response(uri)
|
12
14
|
when Net::HTTPSuccess
|
13
15
|
response
|
14
16
|
when Net::HTTPRedirection
|
data/redirect_follow_get.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Toshimaru"]
|
10
10
|
spec.email = ["me@toshimaru.net"]
|
11
11
|
|
12
|
-
spec.summary = %q{redirect_follow_get is simple http get method
|
13
|
-
spec.description = %q{redirect_follow_get is simple http get method
|
12
|
+
spec.summary = %q{redirect_follow_get is simple http get method following redirect.}
|
13
|
+
spec.description = %q{redirect_follow_get is simple http get method following redirect.}
|
14
14
|
spec.homepage = "https://github.com/toshimaru/redirect_follow_get"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redirect_follow_get
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshimaru
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: redirect_follow_get is simple http get method
|
69
|
+
description: redirect_follow_get is simple http get method following redirect.
|
70
70
|
email:
|
71
71
|
- me@toshimaru.net
|
72
72
|
executables: []
|
@@ -107,5 +107,5 @@ rubyforge_project:
|
|
107
107
|
rubygems_version: 2.5.1
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
|
-
summary: redirect_follow_get is simple http get method
|
110
|
+
summary: redirect_follow_get is simple http get method following redirect.
|
111
111
|
test_files: []
|