http.rb 0.11.1 → 0.12.0
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/README.md +86 -0
- data/http.rb.gemspec +4 -4
- data/lib/HTTP/get.rb +11 -4
- data/lib/HTTP/post.rb +11 -4
- data/lib/Net/HTTP/set_options.rb +16 -0
- data/spec/HTTP/get_spec.rb +45 -8
- data/spec/HTTP/post_spec.rb +49 -12
- data/spec/spec_helper.rb +0 -1
- metadata +6 -6
- data/spec/HTTP.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 751b8b4052533b0498e04222713234378e7a0eb2
|
4
|
+
data.tar.gz: f14d21a8c49ac437c252f03be490a139e5551126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ac92d7be20b5d4e260ed369a974b36c988f6f059eefeb6eddb04cbeb3fc6bd67c325ebd02093660deb6201f799ae028a13fed64f4ce1e0289199742d4b0afe1
|
7
|
+
data.tar.gz: 0b4abaec5371343017d3d42c2d24b9f3e84fcc2b0a29feef493a8f695bd9f3f1b4162dde3522cd4b26cd508790db4145a08a94e04e254c9bdb28c8df87bd4686
|
data/README.md
CHANGED
@@ -89,6 +89,92 @@ end
|
|
89
89
|
|
90
90
|
```
|
91
91
|
|
92
|
+
## Allowed values for the options hash (which passes through to Net::HTTP)
|
93
|
+
```Ruby
|
94
|
+
ca_file
|
95
|
+
# Sets path of a CA certification file in PEM format.
|
96
|
+
#
|
97
|
+
# The file can contain several CA certificates.
|
98
|
+
|
99
|
+
ca_path
|
100
|
+
# Sets path of a CA certification directory containing certifications in
|
101
|
+
# PEM format.
|
102
|
+
|
103
|
+
cert
|
104
|
+
# Sets an OpenSSL::X509::Certificate object as client certificate.
|
105
|
+
# (This method is appeared in Michal Rokos's OpenSSL extension).
|
106
|
+
|
107
|
+
cert_store
|
108
|
+
# Sets the X509::Store to verify peer certificate.
|
109
|
+
|
110
|
+
ciphers
|
111
|
+
# Sets the available ciphers. See OpenSSL::SSL::SSLContext#ciphers=
|
112
|
+
|
113
|
+
close_on_empty_response
|
114
|
+
|
115
|
+
continue_timeout
|
116
|
+
# Number of seconds to wait for one block to be read (via one read(2)
|
117
|
+
# call). Any number may be used, including Floats for fractional
|
118
|
+
# seconds. If the HTTP object cannot read data in this many seconds,
|
119
|
+
# it raises a Net::ReadTimeout exception. The default value is 60 seconds.
|
120
|
+
|
121
|
+
keep_alive_timeout
|
122
|
+
# Seconds to reuse the connection of the previous request.
|
123
|
+
# If the idle time is less than this Keep-Alive Timeout,
|
124
|
+
# Net::HTTP reuses the TCP/IP socket used by the previous communication.
|
125
|
+
# The default value is 2 seconds.
|
126
|
+
|
127
|
+
key
|
128
|
+
# Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
|
129
|
+
# (This method is appeared in Michal Rokos's OpenSSL extension.)
|
130
|
+
|
131
|
+
local_host
|
132
|
+
# The local host used to establish the connection.
|
133
|
+
|
134
|
+
local_port
|
135
|
+
# The local port used to establish the connection.
|
136
|
+
|
137
|
+
open_timeout
|
138
|
+
# Number of seconds to wait for the connection to open. Any number
|
139
|
+
# may be used, including Floats for fractional seconds. If the HTTP
|
140
|
+
# object cannot open a connection in this many seconds, it raises a
|
141
|
+
# Net::OpenTimeout exception. The default value is 60 seconds.
|
142
|
+
|
143
|
+
proxy_address
|
144
|
+
proxy_from_env
|
145
|
+
proxy_pass
|
146
|
+
proxy_port
|
147
|
+
proxy_user
|
148
|
+
|
149
|
+
read_timeout
|
150
|
+
# Seconds to wait for 100 Continue response. If the HTTP object does not
|
151
|
+
# receive a response in this many seconds it sends the request body. The
|
152
|
+
# default value is +nil+.
|
153
|
+
|
154
|
+
ssl_timeout
|
155
|
+
# Sets the SSL timeout seconds.
|
156
|
+
|
157
|
+
ssl_version
|
158
|
+
# Sets the SSL version. See OpenSSL::SSL::SSLContext#ssl_version=
|
159
|
+
|
160
|
+
use_ssl
|
161
|
+
# Turn on/off SSL.
|
162
|
+
# This flag must be set before starting session.
|
163
|
+
# If you change use_ssl value after session started,
|
164
|
+
# a Net::HTTP object raises IOError.
|
165
|
+
|
166
|
+
verify_callback
|
167
|
+
# Sets the verify callback for the server certification verification.
|
168
|
+
|
169
|
+
verify_depth
|
170
|
+
# Sets the maximum depth for the certificate chain verification.
|
171
|
+
|
172
|
+
verify_mode
|
173
|
+
# Sets the flags for server the certification verification at beginning of
|
174
|
+
# SSL/TLS session.
|
175
|
+
#
|
176
|
+
# OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
|
177
|
+
```
|
92
178
|
|
93
179
|
## Contributing
|
94
180
|
|
data/http.rb.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
s.name = 'http.rb'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = '
|
2
|
+
s.name = 'http.rb' # I would have preferred 'http', but there's a library called http.rb with the gem name of http. Confusing, eh?
|
3
|
+
s.version = '0.12.0'
|
4
|
+
s.date = '2017-10-07'
|
5
5
|
|
6
6
|
s.summary = "HTTP made easy."
|
7
7
|
s.description = "HTTP is the simplest HTTP mezzanine library for Ruby. Supply a URI, \
|
8
|
-
some optional query arguments, some optional headers, and some
|
8
|
+
some optional query arguments, some optional headers, and some \
|
9
9
|
Net::HTTP options, and that's it!"
|
10
10
|
s.author = 'thoran'
|
11
11
|
s.email = 'code@thoran.com'
|
data/lib/HTTP/get.rb
CHANGED
@@ -9,6 +9,7 @@ lib_dir = File.expand_path(File.join(__FILE__, '..', '..'))
|
|
9
9
|
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
10
10
|
|
11
11
|
require 'Hash/x_www_form_urlencode'
|
12
|
+
require 'Net/HTTP/set_options'
|
12
13
|
require 'Net/HTTP/Get/set_headers'
|
13
14
|
require 'URI/Generic/use_sslQ'
|
14
15
|
|
@@ -17,15 +18,21 @@ module HTTP
|
|
17
18
|
def get(uri, args = {}, headers = {}, options = {}, &block)
|
18
19
|
uri = uri.is_a?(URI) ? uri : URI.parse(uri)
|
19
20
|
http = Net::HTTP.new(uri.host, uri.port)
|
20
|
-
|
21
|
-
|
22
|
-
options
|
21
|
+
options[:use_ssl] ||= uri.use_ssl?
|
22
|
+
options[:verify_mode] ||= OpenSSL::SSL::VERIFY_NONE
|
23
|
+
http.options = options
|
23
24
|
request_object = Net::HTTP::Get.new(uri.request_uri + '?' + args.x_www_form_urlencode)
|
24
25
|
request_object.headers = headers
|
25
26
|
request_object.basic_auth(uri.user, uri.password) if uri.user
|
26
27
|
response = http.request(request_object)
|
27
28
|
if response.code =~ /^3/
|
28
|
-
|
29
|
+
redirect_uri = URI.parse(response.header['location'])
|
30
|
+
if redirect_uri.scheme
|
31
|
+
response = get(response.header['location'], {}, {}, options, &block)
|
32
|
+
else
|
33
|
+
new_location = "http://#{uri.host}:#{uri.port}#{response.header['location']}"
|
34
|
+
response = get(new_location, {}, {}, options, &block)
|
35
|
+
end
|
29
36
|
end
|
30
37
|
if block_given?
|
31
38
|
yield response
|
data/lib/HTTP/post.rb
CHANGED
@@ -9,6 +9,7 @@ lib_dir = File.expand_path(File.join(__FILE__, '..', '..'))
|
|
9
9
|
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
10
10
|
|
11
11
|
require 'HTTP/get'
|
12
|
+
require 'Net/HTTP/set_options'
|
12
13
|
require 'Net/HTTP/Post/set_headers'
|
13
14
|
require 'URI/Generic/use_sslQ'
|
14
15
|
|
@@ -17,16 +18,22 @@ module HTTP
|
|
17
18
|
def post(uri, form_data = {}, headers = {}, options = {}, &block)
|
18
19
|
uri = uri.is_a?(URI) ? uri : URI.parse(uri)
|
19
20
|
http = Net::HTTP.new(uri.host, uri.port)
|
20
|
-
|
21
|
-
|
22
|
-
options
|
21
|
+
options[:use_ssl] ||= uri.use_ssl?
|
22
|
+
options[:verify_mode] ||= OpenSSL::SSL::VERIFY_NONE
|
23
|
+
http.options = options
|
23
24
|
request_object = Net::HTTP::Post.new(uri.request_uri)
|
24
25
|
request_object.form_data = form_data
|
25
26
|
request_object.headers = headers
|
26
27
|
request_object.basic_auth(uri.user, uri.password) if uri.user
|
27
28
|
response = http.request(request_object)
|
28
29
|
if response.code =~ /^3/
|
29
|
-
|
30
|
+
redirect_uri = URI.parse(response.header['location'])
|
31
|
+
if redirect_uri.scheme
|
32
|
+
response = get(response.header['location'], {}, {}, options, &block)
|
33
|
+
else
|
34
|
+
new_location = "http://#{uri.host}:#{uri.port}#{response.header['location']}"
|
35
|
+
response = get(new_location, {}, {}, options, &block)
|
36
|
+
end
|
30
37
|
end
|
31
38
|
if block_given?
|
32
39
|
yield response
|
data/spec/HTTP/get_spec.rb
CHANGED
@@ -6,9 +6,6 @@ $LOAD_PATH.unshift(spec_dir) unless $LOAD_PATH.include?(spec_dir)
|
|
6
6
|
require 'spec_helper'
|
7
7
|
require 'HTTP/get'
|
8
8
|
|
9
|
-
WebMock.enable!
|
10
|
-
WebMock.disable_net_connect!(allow_localhost: true)
|
11
|
-
|
12
9
|
describe ".get" do
|
13
10
|
|
14
11
|
context "with uri-only supplied" do
|
@@ -144,12 +141,12 @@ describe ".get" do
|
|
144
141
|
before do
|
145
142
|
stub_request(:get, request_uri).
|
146
143
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
147
|
-
to_return(status:
|
144
|
+
to_return(status: 301, body: '', headers: {'location' => redirect_uri})
|
148
145
|
end
|
149
146
|
|
150
147
|
it "does a redirect" do
|
151
148
|
expect(HTTP).to receive(:get).once.with(request_uri).and_call_original
|
152
|
-
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {})
|
149
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
153
150
|
HTTP.get(request_uri)
|
154
151
|
end
|
155
152
|
end
|
@@ -158,12 +155,52 @@ describe ".get" do
|
|
158
155
|
before do
|
159
156
|
stub_request(:get, request_uri).
|
160
157
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
161
|
-
to_return(status:
|
158
|
+
to_return(status: 302, body: '', headers: {'location' => redirect_uri})
|
162
159
|
end
|
163
160
|
|
164
161
|
it "does a redirect" do
|
165
|
-
expect(HTTP).to receive(:get).with(request_uri).and_call_original
|
166
|
-
expect(HTTP).to receive(:get).with(redirect_uri, {}, {}, {})
|
162
|
+
expect(HTTP).to receive(:get).once.with(request_uri).and_call_original
|
163
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
164
|
+
HTTP.get(request_uri)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "with path only redirection" do
|
170
|
+
let(:request_uri){'http://example.com/path'}
|
171
|
+
let(:redirect_path){'/new_path'}
|
172
|
+
let(:redirect_uri){"http://example.com:80#{redirect_path}"}
|
173
|
+
|
174
|
+
before do
|
175
|
+
stub_request(:get, redirect_uri).
|
176
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
177
|
+
to_return(status: 200, body: '', headers: {})
|
178
|
+
end
|
179
|
+
|
180
|
+
context "via 301" do
|
181
|
+
before do
|
182
|
+
stub_request(:get, request_uri).
|
183
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
184
|
+
to_return(status: 301, body: '', headers: {'location' => redirect_path})
|
185
|
+
end
|
186
|
+
|
187
|
+
it "does a redirect" do
|
188
|
+
expect(HTTP).to receive(:get).once.with(request_uri).and_call_original
|
189
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
190
|
+
HTTP.get(request_uri)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context "via 302" do
|
195
|
+
before do
|
196
|
+
stub_request(:get, request_uri).
|
197
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
198
|
+
to_return(status: 302, body: '', headers: {'location' => redirect_path})
|
199
|
+
end
|
200
|
+
|
201
|
+
it "does a redirect" do
|
202
|
+
expect(HTTP).to receive(:get).once.with(request_uri).and_call_original
|
203
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
167
204
|
HTTP.get(request_uri)
|
168
205
|
end
|
169
206
|
end
|
data/spec/HTTP/post_spec.rb
CHANGED
@@ -6,15 +6,12 @@ $LOAD_PATH.unshift(spec_dir) unless $LOAD_PATH.include?(spec_dir)
|
|
6
6
|
require 'spec_helper'
|
7
7
|
require 'HTTP/post'
|
8
8
|
|
9
|
-
WebMock.enable!
|
10
|
-
WebMock.disable_net_connect!(allow_localhost: true)
|
11
|
-
|
12
9
|
describe ".post" do
|
13
10
|
|
14
11
|
context "with uri-only supplied" do
|
15
12
|
before do
|
16
13
|
stub_request(:post, 'http://example.com/path').
|
17
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
14
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'}).
|
18
15
|
to_return(status: 200, body: '', headers: {})
|
19
16
|
end
|
20
17
|
|
@@ -61,7 +58,7 @@ describe ".post" do
|
|
61
58
|
|
62
59
|
before do
|
63
60
|
stub_request(:post, "http://example.com/path").
|
64
|
-
with(body: {"a"=>"1", "b"=>"2"}, headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
61
|
+
with(body: {"a"=>"1", "b"=>"2"}, headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'}).
|
65
62
|
to_return(status: 200, body: '', headers: {})
|
66
63
|
end
|
67
64
|
|
@@ -86,7 +83,7 @@ describe ".post" do
|
|
86
83
|
|
87
84
|
before do
|
88
85
|
stub_request(:post, 'http://example.com/path').
|
89
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Rspec'}).
|
86
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Rspec'}).
|
90
87
|
to_return(status: 200, body: '', headers: {})
|
91
88
|
end
|
92
89
|
|
@@ -105,7 +102,7 @@ describe ".post" do
|
|
105
102
|
|
106
103
|
before do
|
107
104
|
stub_request(:post, 'https://example.com:80/path').
|
108
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
105
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'}).
|
109
106
|
to_return(status: 200, body: '', headers: {})
|
110
107
|
end
|
111
108
|
|
@@ -121,7 +118,7 @@ describe ".post" do
|
|
121
118
|
|
122
119
|
before do
|
123
120
|
stub_request(:post, 'http://example.com/path').
|
124
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
121
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'}).
|
125
122
|
to_return(status: 200, body: '', headers: {})
|
126
123
|
end
|
127
124
|
|
@@ -145,12 +142,12 @@ describe ".post" do
|
|
145
142
|
before do
|
146
143
|
stub_request(:post, request_uri).
|
147
144
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
148
|
-
to_return(status:
|
145
|
+
to_return(status: 301, body: '', headers: {'location' => redirect_uri})
|
149
146
|
end
|
150
147
|
|
151
148
|
it "does a redirect" do
|
152
149
|
expect(HTTP).to receive(:post).once.with(request_uri).and_call_original
|
153
|
-
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {})
|
150
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
154
151
|
HTTP.post(request_uri)
|
155
152
|
end
|
156
153
|
end
|
@@ -159,12 +156,52 @@ describe ".post" do
|
|
159
156
|
before do
|
160
157
|
stub_request(:post, request_uri).
|
161
158
|
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
162
|
-
to_return(status:
|
159
|
+
to_return(status: 302, body: '', headers: {'location' => redirect_uri})
|
163
160
|
end
|
164
161
|
|
165
162
|
it "does a redirect" do
|
166
163
|
expect(HTTP).to receive(:post).with(request_uri).and_call_original
|
167
|
-
expect(HTTP).to receive(:get).with(redirect_uri, {}, {}, {})
|
164
|
+
expect(HTTP).to receive(:get).with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
165
|
+
HTTP.post(request_uri)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context "with path only redirection" do
|
171
|
+
let(:request_uri){'http://example.com/path'}
|
172
|
+
let(:redirect_path){'/new_path'}
|
173
|
+
let(:redirect_uri){"http://example.com:80#{redirect_path}"}
|
174
|
+
|
175
|
+
before do
|
176
|
+
stub_request(:get, redirect_uri).
|
177
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
178
|
+
to_return(status: 200, body: '', headers: {})
|
179
|
+
end
|
180
|
+
|
181
|
+
context "via 301" do
|
182
|
+
before do
|
183
|
+
stub_request(:post, request_uri).
|
184
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
185
|
+
to_return(status: 301, body: '', headers: {'location' => redirect_path})
|
186
|
+
end
|
187
|
+
|
188
|
+
it "does a redirect" do
|
189
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
190
|
+
expect(HTTP).to receive(:post).once.with(request_uri).and_call_original
|
191
|
+
HTTP.post(request_uri)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "via 302" do
|
196
|
+
before do
|
197
|
+
stub_request(:post, request_uri).
|
198
|
+
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'}).
|
199
|
+
to_return(status: 302, body: '', headers: {'location' => redirect_path})
|
200
|
+
end
|
201
|
+
|
202
|
+
it "does a redirect" do
|
203
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0})
|
204
|
+
expect(HTTP).to receive(:post).once.with(request_uri).and_call_original
|
168
205
|
HTTP.post(request_uri)
|
169
206
|
end
|
170
207
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: HTTP is the simplest HTTP mezzanine library for Ruby. Supply a URI, some
|
14
|
-
optional query arguments, some optional headers, and some
|
15
|
-
|
14
|
+
optional query arguments, some optional headers, and some Net::HTTP options,
|
15
|
+
and that's it!
|
16
16
|
email: code@thoran.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
@@ -27,9 +27,9 @@ files:
|
|
27
27
|
- lib/Hash/x_www_form_urlencode.rb
|
28
28
|
- lib/Net/HTTP/Get/set_headers.rb
|
29
29
|
- lib/Net/HTTP/Post/set_headers.rb
|
30
|
+
- lib/Net/HTTP/set_options.rb
|
30
31
|
- lib/String/url_encode.rb
|
31
32
|
- lib/URI/Generic/use_sslQ.rb
|
32
|
-
- spec/HTTP.rb
|
33
33
|
- spec/HTTP/get_spec.rb
|
34
34
|
- spec/HTTP/post_spec.rb
|
35
35
|
- spec/spec_helper.rb
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
54
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
55
|
+
rubygems_version: 2.5.2
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: HTTP made easy.
|
data/spec/HTTP.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# spec/HTTP.rb
|
2
|
-
|
3
|
-
spec_dir = File.expand_path(File.join(__FILE__, '..'))
|
4
|
-
$LOAD_PATH.unshift(spec_dir) unless $LOAD_PATH.include?(spec_dir)
|
5
|
-
|
6
|
-
require 'spec_helper'
|
7
|
-
|
8
|
-
require 'HTTP/get'
|
9
|
-
require 'HTTP/post'
|
10
|
-
|
11
|
-
require 'HTTP/get_spec'
|
12
|
-
require 'HTTP/post_spec'
|