http.rb 0.15.0 → 0.16.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/CHANGELOG.txt +23 -0
- data/http.rb.gemspec +1 -1
- data/lib/HTTP/VERSION.rb +1 -1
- data/lib/HTTP/delete.rb +1 -0
- data/lib/HTTP/post.rb +12 -3
- data/lib/HTTP/put.rb +16 -5
- data/lib/HTTP.rb +2 -0
- data/spec/HTTP/post_spec.rb +62 -4
- data/spec/HTTP/put_spec.rb +110 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1bb42ba9827c2b10169f1b07d2069e915dec971e178b2d91f5bbb9c0fe88b95
|
4
|
+
data.tar.gz: 416d60a22b86594a059fe05d5747ea51c4728dda0f3626e8214f06e5e56304aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc19d82645746f5e386b4a32e7a9fd297123c65e56ad1e45f26f4a3c88f5d383a90f477721aadc953cae11c7d97fbd2654030003b286271642a260cac133eb75
|
7
|
+
data.tar.gz: 3fc2406bd6b52e34a1da18306fa22c8f2765343b6cc5c224b9200cef9d1d29192ee7061921457877ffd0a81cb93355fadb61749a2004cddb70e32196136323e6
|
data/CHANGELOG.txt
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# 20250809
|
2
|
+
# 0.16.0: Allow passing of a raw payload for POST/PUT.
|
3
|
+
1. ~ HTTP.post: Check for Content-Type and whether a string.
|
4
|
+
2. ~ HTTP.put: Check for Content-Type and whether a string.
|
5
|
+
3. ~ spec/HTTP/post_spec.rb: + raw form data example
|
6
|
+
4. ~ spec/HTTP/post_spec.rb: + raw JSON example
|
7
|
+
5. ~ spec/HTTP/put_spec.rb: + raw form data example
|
8
|
+
6. ~ spec/HTTP/put_spec.rb: + raw JSON example
|
9
|
+
7. ~ HTTP::VERSION: /0.15.1/0.16.0/
|
10
|
+
8. ~ CHANGELOG.txt: + 0.16.0 entry; Small edit on 0.15.1.
|
11
|
+
9. ~ http.rb.gemspec: Change date.
|
12
|
+
|
13
|
+
# 20250721
|
14
|
+
# 0.15.1: Fix PUT; require delete and put in the load file.
|
15
|
+
1. + require 'HTTP/put'
|
16
|
+
2. + require 'HTTP/delete'
|
17
|
+
3. ~ HTTP/put.rb: Params in the body!
|
18
|
+
3. ~ spec/HTTP/put_spec.rb: Remove copy-pasta rubbish.
|
19
|
+
4. ~ spec/HTTP/post_spec.rb: Mostly formatting.
|
20
|
+
4. ~ HTTP::VERSION: /0.15.0/0.15.1/
|
21
|
+
5. ~ CHANGELOG.txt
|
22
|
+
6. ~ http.rb.gemspec: Change date.
|
23
|
+
|
1
24
|
# 20250716
|
2
25
|
# 0.15.0: + PUT
|
3
26
|
1. + HTTP.put
|
data/http.rb.gemspec
CHANGED
@@ -3,7 +3,7 @@ require_relative './lib/HTTP/VERSION'
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'http.rb'
|
5
5
|
s.version = HTTP::VERSION
|
6
|
-
s.date = '2025-
|
6
|
+
s.date = '2025-08-09'
|
7
7
|
|
8
8
|
s.summary = "HTTP made easy."
|
9
9
|
s.description = "HTTP is the simplest HTTP mezzanine library for Ruby. Supply a URI, \
|
data/lib/HTTP/VERSION.rb
CHANGED
data/lib/HTTP/delete.rb
CHANGED
@@ -6,6 +6,7 @@ require 'openssl'
|
|
6
6
|
require 'uri'
|
7
7
|
|
8
8
|
require_relative '../Hash/x_www_form_urlencode'
|
9
|
+
require_relative '../HTTP/get'
|
9
10
|
require_relative '../Net/HTTP/set_options'
|
10
11
|
require_relative '../Net/HTTP/Delete/set_headers'
|
11
12
|
require_relative '../Net/HTTPResponse/StatusPredicates'
|
data/lib/HTTP/post.rb
CHANGED
@@ -22,10 +22,19 @@ module HTTP
|
|
22
22
|
options[:verify_mode] ||= OpenSSL::SSL::VERIFY_NONE
|
23
23
|
http.options = options
|
24
24
|
request_object = Net::HTTP::Post.new(uri.request_uri)
|
25
|
-
|
26
|
-
|
25
|
+
content_type = headers['Content-Type'].to_s
|
26
|
+
if content_type.start_with?('application/json')
|
27
|
+
if data.is_a?(String)
|
28
|
+
request_object.body = data
|
29
|
+
else
|
30
|
+
request_object.body = JSON.dump(data)
|
31
|
+
end
|
27
32
|
else
|
28
|
-
|
33
|
+
if data.is_a?(String)
|
34
|
+
request_object.body = data
|
35
|
+
else
|
36
|
+
request_object.form_data = data
|
37
|
+
end
|
29
38
|
end
|
30
39
|
request_object.headers = headers
|
31
40
|
request_object.basic_auth(uri.user, uri.password) if uri.user
|
data/lib/HTTP/put.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# HTTP/put.rb
|
2
2
|
# HTTP.put
|
3
3
|
|
4
|
+
require 'json'
|
4
5
|
require 'net/http'
|
5
6
|
require 'openssl'
|
6
7
|
require 'uri'
|
7
8
|
|
8
|
-
require_relative '../
|
9
|
+
require_relative '../HTTP/get'
|
9
10
|
require_relative '../Net/HTTP/set_options'
|
10
11
|
require_relative '../Net/HTTP/Put/set_headers'
|
11
12
|
require_relative '../Net/HTTPResponse/StatusPredicates'
|
@@ -13,17 +14,27 @@ require_relative '../URI/Generic/use_sslQ'
|
|
13
14
|
|
14
15
|
module HTTP
|
15
16
|
|
16
|
-
def put(uri,
|
17
|
+
def put(uri, data = {}, headers = {}, options = {}, &block)
|
17
18
|
uri = uri.is_a?(URI) ? uri : URI.parse(uri)
|
18
19
|
http = Net::HTTP.new(uri.host, uri.port)
|
19
20
|
no_redirect = options.delete(:no_redirect)
|
20
21
|
options[:use_ssl] ||= uri.use_ssl?
|
21
22
|
options[:verify_mode] ||= OpenSSL::SSL::VERIFY_NONE
|
22
23
|
http.options = options
|
23
|
-
|
24
|
-
|
24
|
+
request_object = Net::HTTP::Put.new(uri.request_uri)
|
25
|
+
content_type = headers['Content-Type'].to_s
|
26
|
+
if content_type.start_with?('application/json')
|
27
|
+
if data.is_a?(String)
|
28
|
+
request_object.body = data
|
29
|
+
else
|
30
|
+
request_object.body = JSON.dump(data)
|
31
|
+
end
|
25
32
|
else
|
26
|
-
|
33
|
+
if data.is_a?(String)
|
34
|
+
request_object.body = data
|
35
|
+
else
|
36
|
+
request_object.form_data = data
|
37
|
+
end
|
27
38
|
end
|
28
39
|
request_object.headers = headers
|
29
40
|
request_object.basic_auth(uri.user, uri.password) if uri.user
|
data/lib/HTTP.rb
CHANGED
data/spec/HTTP/post_spec.rb
CHANGED
@@ -77,6 +77,35 @@ describe ".post" do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
context "with raw form data supplied" do
|
81
|
+
let(:uri){'http://example.com/path'}
|
82
|
+
let(:parsed_uri){URI.parse(uri)}
|
83
|
+
let(:args) do; {a: 1, b: 2}.x_www_form_urlencode; end
|
84
|
+
let(:headers) do; {'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'}; end
|
85
|
+
let(:encoded_form_data){args}
|
86
|
+
let(:request_uri){parsed_uri.request_uri}
|
87
|
+
let(:request_object){Net::HTTP::Post.new(request_uri)}
|
88
|
+
|
89
|
+
before do
|
90
|
+
stub_request(:post, "http://example.com/path").
|
91
|
+
with(body: encoded_form_data, headers: headers).
|
92
|
+
to_return(status: 200, body: '', headers: {})
|
93
|
+
end
|
94
|
+
|
95
|
+
it "sets the form data" do
|
96
|
+
allow(Net::HTTP::Post).to receive(:new).with(request_uri).and_return(request_object)
|
97
|
+
response = HTTP.post(uri, args, headers)
|
98
|
+
expect(request_object.body).to eq(encoded_form_data)
|
99
|
+
expect(response.success?).to eq(true)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "creates a new Net::HTTP::Post object" do
|
103
|
+
expect(Net::HTTP::Post).to receive(:new).with(request_uri).and_return(request_object)
|
104
|
+
response = HTTP.post(uri, args, headers)
|
105
|
+
expect(response.success?).to eq(true)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
80
109
|
context "with JSON data supplied" do
|
81
110
|
let(:uri){'http://example.com/path'}
|
82
111
|
let(:parsed_uri){URI.parse(uri)}
|
@@ -106,6 +135,35 @@ describe ".post" do
|
|
106
135
|
end
|
107
136
|
end
|
108
137
|
|
138
|
+
context "with raw JSON data supplied" do
|
139
|
+
let(:uri){'http://example.com/path'}
|
140
|
+
let(:parsed_uri){URI.parse(uri)}
|
141
|
+
let(:args) do; JSON.dump({a: 1, b: 2}); end
|
142
|
+
let(:headers) do; {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}; end
|
143
|
+
let(:json_data){args}
|
144
|
+
let(:request_uri){parsed_uri.request_uri}
|
145
|
+
let(:request_object){Net::HTTP::Post.new(request_uri)}
|
146
|
+
|
147
|
+
before do
|
148
|
+
stub_request(:post, "http://example.com/path").
|
149
|
+
with(body: json_data, headers: headers).
|
150
|
+
to_return(status: 200, body: '', headers: {})
|
151
|
+
end
|
152
|
+
|
153
|
+
it "sets the body" do
|
154
|
+
allow(Net::HTTP::Post).to receive(:new).with(request_uri).and_return(request_object)
|
155
|
+
response = HTTP.post(uri, args, headers)
|
156
|
+
expect(request_object.body).to eq(json_data)
|
157
|
+
expect(response.success?).to eq(true)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "creates a new Net::HTTP::Post object" do
|
161
|
+
expect(Net::HTTP::Post).to receive(:new).with(request_uri).and_return(request_object)
|
162
|
+
response = HTTP.post(uri, args, headers)
|
163
|
+
expect(response.success?).to eq(true)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
109
167
|
context "with headers supplied" do
|
110
168
|
let(:uri){'http://example.com/path'}
|
111
169
|
let(:parsed_uri){URI.parse(uri)}
|
@@ -194,8 +252,8 @@ describe ".post" do
|
|
194
252
|
end
|
195
253
|
|
196
254
|
it "does a redirect" do
|
197
|
-
expect(HTTP).to receive(:post).with(request_uri).and_call_original
|
198
|
-
expect(HTTP).to receive(:get).with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0}).and_call_original
|
255
|
+
expect(HTTP).to receive(:post).once.with(request_uri).and_call_original
|
256
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0}).and_call_original
|
199
257
|
response = HTTP.post(request_uri)
|
200
258
|
expect(response.success?).to eq(true)
|
201
259
|
end
|
@@ -221,8 +279,8 @@ describe ".post" do
|
|
221
279
|
end
|
222
280
|
|
223
281
|
it "does a redirect" do
|
224
|
-
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0}).and_call_original
|
225
282
|
expect(HTTP).to receive(:post).once.with(request_uri).and_call_original
|
283
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0}).and_call_original
|
226
284
|
response = HTTP.post(request_uri)
|
227
285
|
expect(response.success?).to eq(true)
|
228
286
|
end
|
@@ -236,8 +294,8 @@ describe ".post" do
|
|
236
294
|
end
|
237
295
|
|
238
296
|
it "does a redirect" do
|
239
|
-
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0}).and_call_original
|
240
297
|
expect(HTTP).to receive(:post).once.with(request_uri).and_call_original
|
298
|
+
expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: false, verify_mode: 0}).and_call_original
|
241
299
|
response = HTTP.post(request_uri)
|
242
300
|
expect(response.success?).to eq(true)
|
243
301
|
end
|
data/spec/HTTP/put_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe ".put" do
|
|
7
7
|
context "with uri-only supplied" do
|
8
8
|
before do
|
9
9
|
stub_request(:put, 'http://example.com/path').
|
10
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
10
|
+
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'}).
|
11
11
|
to_return(status: 200, body: '', headers: {})
|
12
12
|
end
|
13
13
|
|
@@ -36,7 +36,8 @@ describe ".put" do
|
|
36
36
|
|
37
37
|
it "returns an instance of URI" do
|
38
38
|
expect(uri).to eq(uri)
|
39
|
-
HTTP.put(uri)
|
39
|
+
response = HTTP.put(uri)
|
40
|
+
expect(response.success?).to eq(true)
|
40
41
|
end
|
41
42
|
|
42
43
|
it "creates a new Net::HTTP object" do
|
@@ -47,29 +48,118 @@ describe ".put" do
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
context "with
|
51
|
+
context "with form data supplied" do
|
51
52
|
let(:uri){'http://example.com/path'}
|
52
53
|
let(:parsed_uri){URI.parse(uri)}
|
53
54
|
let(:args) do; {a: 1, b: 2}; end
|
54
|
-
let(:
|
55
|
-
let(:
|
56
|
-
let(:
|
55
|
+
let(:headers) do; {'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'}; end
|
56
|
+
let(:encoded_form_data){args.x_www_form_urlencode}
|
57
|
+
let(:request_uri){parsed_uri.request_uri}
|
58
|
+
let(:request_object){Net::HTTP::Put.new(request_uri)}
|
57
59
|
|
58
60
|
before do
|
59
|
-
stub_request(:put,
|
60
|
-
with(
|
61
|
+
stub_request(:put, "http://example.com/path").
|
62
|
+
with(body: encoded_form_data, headers: headers).
|
61
63
|
to_return(status: 200, body: '', headers: {})
|
62
64
|
end
|
63
65
|
|
64
|
-
it "
|
65
|
-
|
66
|
-
response = HTTP.put(uri, args)
|
66
|
+
it "sets the form data" do
|
67
|
+
allow(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
68
|
+
response = HTTP.put(uri, args, headers)
|
69
|
+
expect(request_object.body).to eq(encoded_form_data)
|
67
70
|
expect(response.success?).to eq(true)
|
68
71
|
end
|
69
72
|
|
70
|
-
it "creates a new Net::HTTP::
|
71
|
-
expect(Net::HTTP::Put).to receive(:new).with(
|
72
|
-
response = HTTP.put(uri, args)
|
73
|
+
it "creates a new Net::HTTP::Post object" do
|
74
|
+
expect(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
75
|
+
response = HTTP.put(uri, args, headers)
|
76
|
+
expect(response.success?).to eq(true)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "with raw form data supplied" do
|
81
|
+
let(:uri){'http://example.com/path'}
|
82
|
+
let(:parsed_uri){URI.parse(uri)}
|
83
|
+
let(:args) do; {a: 1, b: 2}.x_www_form_urlencode; end
|
84
|
+
let(:headers) do; {'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'}; end
|
85
|
+
let(:encoded_form_data){args}
|
86
|
+
let(:request_uri){parsed_uri.request_uri}
|
87
|
+
let(:request_object){Net::HTTP::Put.new(request_uri)}
|
88
|
+
|
89
|
+
before do
|
90
|
+
stub_request(:put, "http://example.com/path").
|
91
|
+
with(body: encoded_form_data, headers: headers).
|
92
|
+
to_return(status: 200, body: '', headers: {})
|
93
|
+
end
|
94
|
+
|
95
|
+
it "sets the form data" do
|
96
|
+
allow(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
97
|
+
response = HTTP.put(uri, args, headers)
|
98
|
+
expect(request_object.body).to eq(encoded_form_data)
|
99
|
+
expect(response.success?).to eq(true)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "creates a new Net::HTTP::Post object" do
|
103
|
+
expect(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
104
|
+
response = HTTP.put(uri, args, headers)
|
105
|
+
expect(response.success?).to eq(true)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "with JSON data supplied" do
|
110
|
+
let(:uri){'http://example.com/path'}
|
111
|
+
let(:parsed_uri){URI.parse(uri)}
|
112
|
+
let(:args) do; {a: 1, b: 2}; end
|
113
|
+
let(:headers) do; {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}; end
|
114
|
+
let(:json_data){JSON.dump(args)}
|
115
|
+
let(:request_uri){parsed_uri.request_uri}
|
116
|
+
let(:request_object){Net::HTTP::Put.new(request_uri)}
|
117
|
+
|
118
|
+
before do
|
119
|
+
stub_request(:put, "http://example.com/path").
|
120
|
+
with(body: json_data, headers: headers).
|
121
|
+
to_return(status: 200, body: '', headers: {})
|
122
|
+
end
|
123
|
+
|
124
|
+
it "sets the body" do
|
125
|
+
allow(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
126
|
+
response = HTTP.put(uri, args, headers)
|
127
|
+
expect(request_object.body).to eq(json_data)
|
128
|
+
expect(response.success?).to eq(true)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "creates a new Net::HTTP::Post object" do
|
132
|
+
expect(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
133
|
+
response = HTTP.put(uri, args, headers)
|
134
|
+
expect(response.success?).to eq(true)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "with raw JSON data supplied" do
|
139
|
+
let(:uri){'http://example.com/path'}
|
140
|
+
let(:parsed_uri){URI.parse(uri)}
|
141
|
+
let(:args) do; JSON.dump({a: 1, b: 2}); end
|
142
|
+
let(:headers) do; {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}; end
|
143
|
+
let(:json_data){args}
|
144
|
+
let(:request_uri){parsed_uri.request_uri}
|
145
|
+
let(:request_object){Net::HTTP::Put.new(request_uri)}
|
146
|
+
|
147
|
+
before do
|
148
|
+
stub_request(:put, "http://example.com/path").
|
149
|
+
with(body: json_data, headers: headers).
|
150
|
+
to_return(status: 200, body: '', headers: {})
|
151
|
+
end
|
152
|
+
|
153
|
+
it "sets the body" do
|
154
|
+
allow(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
155
|
+
response = HTTP.put(uri, args, headers)
|
156
|
+
expect(request_object.body).to eq(json_data)
|
157
|
+
expect(response.success?).to eq(true)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "creates a new Net::HTTP::Post object" do
|
161
|
+
expect(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
162
|
+
response = HTTP.put(uri, args, headers)
|
73
163
|
expect(response.success?).to eq(true)
|
74
164
|
end
|
75
165
|
end
|
@@ -78,17 +168,17 @@ describe ".put" do
|
|
78
168
|
let(:uri){'http://example.com/path'}
|
79
169
|
let(:parsed_uri){URI.parse(uri)}
|
80
170
|
let(:headers) do; {'User-Agent' => 'Rspec'}; end
|
81
|
-
let(:
|
82
|
-
let(:request_object){Net::HTTP::Put.new(
|
171
|
+
let(:request_uri){parsed_uri.request_uri}
|
172
|
+
let(:request_object){Net::HTTP::Put.new(request_uri)}
|
83
173
|
|
84
174
|
before do
|
85
175
|
stub_request(:put, 'http://example.com/path').
|
86
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Rspec'}).
|
176
|
+
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'}).
|
87
177
|
to_return(status: 200, body: '', headers: {})
|
88
178
|
end
|
89
179
|
|
90
180
|
it "sets the headers on the request object" do
|
91
|
-
allow(Net::HTTP::Put).to receive(:new).with(
|
181
|
+
allow(Net::HTTP::Put).to receive(:new).with(request_uri).and_return(request_object)
|
92
182
|
response = HTTP.put(uri, {}, headers)
|
93
183
|
expect(request_object['User-Agent']).to eq('Rspec')
|
94
184
|
expect(response.success?).to eq(true)
|
@@ -103,7 +193,7 @@ describe ".put" do
|
|
103
193
|
|
104
194
|
before do
|
105
195
|
stub_request(:put, 'https://example.com:80/path').
|
106
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
196
|
+
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'}).
|
107
197
|
to_return(status: 200, body: '', headers: {})
|
108
198
|
end
|
109
199
|
|
@@ -120,7 +210,7 @@ describe ".put" do
|
|
120
210
|
|
121
211
|
before do
|
122
212
|
stub_request(:put, 'http://example.com/path').
|
123
|
-
with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
|
213
|
+
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'}).
|
124
214
|
to_return(status: 200, body: '', headers: {})
|
125
215
|
end
|
126
216
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoran
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-08-09 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: HTTP is the simplest HTTP mezzanine library for Ruby. Supply a URI, some
|
13
13
|
optional query arguments, some optional headers, and some Net::HTTP options,
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
61
|
+
rubygems_version: 3.7.1
|
62
62
|
specification_version: 4
|
63
63
|
summary: HTTP made easy.
|
64
64
|
test_files: []
|