httparty 0.18.1 → 0.24.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/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +24 -0
- data/.gitignore +2 -1
- data/Changelog.md +402 -308
- data/Gemfile +3 -0
- data/Guardfile +3 -2
- data/README.md +16 -18
- data/docs/README.md +89 -2
- data/examples/README.md +3 -0
- data/examples/aaws.rb +6 -2
- data/examples/idn.rb +10 -0
- data/examples/party_foul_mode.rb +90 -0
- data/httparty.gemspec +4 -2
- data/lib/httparty/connection_adapter.rb +8 -25
- data/lib/httparty/cookie_hash.rb +3 -1
- data/lib/httparty/decompressor.rb +102 -0
- data/lib/httparty/exceptions.rb +37 -4
- data/lib/httparty/hash_conversions.rb +4 -2
- data/lib/httparty/headers_processor.rb +2 -0
- data/lib/httparty/logger/apache_formatter.rb +4 -2
- data/lib/httparty/logger/curl_formatter.rb +5 -3
- data/lib/httparty/logger/logger.rb +2 -0
- data/lib/httparty/logger/logstash_formatter.rb +5 -2
- data/lib/httparty/module_inheritable_attributes.rb +6 -6
- data/lib/httparty/net_digest_auth.rb +9 -10
- data/lib/httparty/parser.rb +12 -5
- data/lib/httparty/request/body.rb +53 -12
- data/lib/httparty/request/multipart_boundary.rb +2 -0
- data/lib/httparty/request/streaming_multipart_body.rb +188 -0
- data/lib/httparty/request.rb +130 -43
- data/lib/httparty/response/headers.rb +2 -0
- data/lib/httparty/response.rb +7 -5
- data/lib/httparty/response_fragment.rb +2 -0
- data/lib/httparty/text_encoder.rb +7 -5
- data/lib/httparty/utils.rb +2 -0
- data/lib/httparty/version.rb +3 -1
- data/lib/httparty.rb +45 -14
- data/script/release +4 -4
- metadata +33 -14
- data/.simplecov +0 -1
- data/.travis.yml +0 -11
data/lib/httparty/request.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'erb'
|
|
2
4
|
|
|
3
5
|
module HTTParty
|
|
@@ -44,6 +46,15 @@ module HTTParty
|
|
|
44
46
|
end.flatten.join('&')
|
|
45
47
|
end
|
|
46
48
|
|
|
49
|
+
def self._load(data)
|
|
50
|
+
http_method, path, options, last_response, last_uri, raw_request = Marshal.load(data)
|
|
51
|
+
instance = new(http_method, path, options)
|
|
52
|
+
instance.last_response = last_response
|
|
53
|
+
instance.last_uri = last_uri
|
|
54
|
+
instance.instance_variable_set("@raw_request", raw_request)
|
|
55
|
+
instance
|
|
56
|
+
end
|
|
57
|
+
|
|
47
58
|
attr_accessor :http_method, :options, :last_response, :redirect, :last_uri
|
|
48
59
|
attr_reader :path
|
|
49
60
|
|
|
@@ -87,11 +98,11 @@ module HTTParty
|
|
|
87
98
|
end
|
|
88
99
|
|
|
89
100
|
def uri
|
|
90
|
-
if redirect && path.relative? && path.path[0] !=
|
|
91
|
-
last_uri_host = @last_uri.path.gsub(/[^\/]+$/,
|
|
101
|
+
if redirect && path.relative? && path.path[0] != '/'
|
|
102
|
+
last_uri_host = @last_uri.path.gsub(/[^\/]+$/, '')
|
|
92
103
|
|
|
93
|
-
path.path = "/#{path.path}" if last_uri_host[-1] !=
|
|
94
|
-
path.path = last_uri_host
|
|
104
|
+
path.path = "/#{path.path}" if last_uri_host[-1] != '/'
|
|
105
|
+
path.path = "#{last_uri_host}#{path.path}"
|
|
95
106
|
end
|
|
96
107
|
|
|
97
108
|
if path.relative? && path.host
|
|
@@ -102,6 +113,8 @@ module HTTParty
|
|
|
102
113
|
new_uri = path.clone
|
|
103
114
|
end
|
|
104
115
|
|
|
116
|
+
validate_uri_safety!(new_uri) unless redirect
|
|
117
|
+
|
|
105
118
|
# avoid double query string on redirects [#12]
|
|
106
119
|
unless redirect
|
|
107
120
|
new_uri.query = query_string(new_uri)
|
|
@@ -117,7 +130,7 @@ module HTTParty
|
|
|
117
130
|
def base_uri
|
|
118
131
|
if redirect
|
|
119
132
|
base_uri = "#{@last_uri.scheme}://#{@last_uri.host}"
|
|
120
|
-
base_uri
|
|
133
|
+
base_uri = "#{base_uri}:#{@last_uri.port}" if @last_uri.port != 80
|
|
121
134
|
base_uri
|
|
122
135
|
else
|
|
123
136
|
options[:base_uri] && HTTParty.normalize_base_uri(options[:base_uri])
|
|
@@ -142,24 +155,28 @@ module HTTParty
|
|
|
142
155
|
chunked_body = nil
|
|
143
156
|
current_http = http
|
|
144
157
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
begin
|
|
159
|
+
self.last_response = current_http.request(@raw_request) do |http_response|
|
|
160
|
+
if block
|
|
161
|
+
chunks = []
|
|
148
162
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
http_response.read_body do |fragment|
|
|
164
|
+
encoded_fragment = encode_text(fragment, http_response['content-type'])
|
|
165
|
+
chunks << encoded_fragment if !options[:stream_body]
|
|
166
|
+
block.call ResponseFragment.new(encoded_fragment, http_response, current_http)
|
|
167
|
+
end
|
|
154
168
|
|
|
155
|
-
|
|
169
|
+
chunked_body = chunks.join
|
|
170
|
+
end
|
|
156
171
|
end
|
|
157
|
-
end
|
|
158
172
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
handle_host_redirection if response_redirects?
|
|
174
|
+
result = handle_unauthorized
|
|
175
|
+
result ||= handle_response(chunked_body, &block)
|
|
176
|
+
result
|
|
177
|
+
rescue *COMMON_NETWORK_ERRORS => e
|
|
178
|
+
raise options[:foul] ? HTTParty::NetworkError.new("#{e.class}: #{e.message}") : e
|
|
179
|
+
end
|
|
163
180
|
end
|
|
164
181
|
|
|
165
182
|
def handle_unauthorized(&block)
|
|
@@ -173,6 +190,13 @@ module HTTParty
|
|
|
173
190
|
@raw_request.body
|
|
174
191
|
end
|
|
175
192
|
|
|
193
|
+
def _dump(_level)
|
|
194
|
+
opts = options.dup
|
|
195
|
+
opts.delete(:logger)
|
|
196
|
+
opts.delete(:parser) if opts[:parser] && opts[:parser].is_a?(Proc)
|
|
197
|
+
Marshal.dump([http_method, path, opts, last_response, @last_uri, @raw_request])
|
|
198
|
+
end
|
|
199
|
+
|
|
176
200
|
private
|
|
177
201
|
|
|
178
202
|
def http
|
|
@@ -223,10 +247,21 @@ module HTTParty
|
|
|
223
247
|
if body.multipart?
|
|
224
248
|
content_type = "multipart/form-data; boundary=#{body.boundary}"
|
|
225
249
|
@raw_request['Content-Type'] = content_type
|
|
250
|
+
elsif options[:body].respond_to?(:to_hash) && !@raw_request['Content-Type']
|
|
251
|
+
@raw_request['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
if body.streaming? && options[:stream_body] != false
|
|
255
|
+
stream = body.to_stream
|
|
256
|
+
@raw_request.body_stream = stream
|
|
257
|
+
@raw_request['Content-Length'] = stream.size.to_s
|
|
258
|
+
else
|
|
259
|
+
@raw_request.body = body.call
|
|
226
260
|
end
|
|
227
|
-
@raw_request.body = body.call
|
|
228
261
|
end
|
|
229
262
|
|
|
263
|
+
@raw_request.instance_variable_set(:@decode_content, decompress_content?)
|
|
264
|
+
|
|
230
265
|
if options[:basic_auth] && send_authorization_header?
|
|
231
266
|
@raw_request.basic_auth(username, password)
|
|
232
267
|
@credentials_sent = true
|
|
@@ -238,6 +273,10 @@ module HTTParty
|
|
|
238
273
|
!!options[:digest_auth]
|
|
239
274
|
end
|
|
240
275
|
|
|
276
|
+
def decompress_content?
|
|
277
|
+
!options[:skip_decompression]
|
|
278
|
+
end
|
|
279
|
+
|
|
241
280
|
def response_unauthorized?
|
|
242
281
|
!!last_response && last_response.code == '401'
|
|
243
282
|
end
|
|
@@ -261,7 +300,7 @@ module HTTParty
|
|
|
261
300
|
query_string_parts << options[:query] unless options[:query].nil?
|
|
262
301
|
end
|
|
263
302
|
|
|
264
|
-
query_string_parts.reject!(&:empty?) unless query_string_parts == [
|
|
303
|
+
query_string_parts.reject!(&:empty?) unless query_string_parts == ['']
|
|
265
304
|
query_string_parts.size > 0 ? query_string_parts.join('&') : nil
|
|
266
305
|
end
|
|
267
306
|
|
|
@@ -269,37 +308,55 @@ module HTTParty
|
|
|
269
308
|
options[:assume_utf16_is_big_endian]
|
|
270
309
|
end
|
|
271
310
|
|
|
272
|
-
def handle_response(
|
|
311
|
+
def handle_response(raw_body, &block)
|
|
273
312
|
if response_redirects?
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
unless options[:maintain_method_across_redirects]
|
|
287
|
-
self.http_method = Net::HTTP::Get
|
|
313
|
+
handle_redirection(&block)
|
|
314
|
+
else
|
|
315
|
+
raw_body ||= last_response.body
|
|
316
|
+
|
|
317
|
+
body = decompress(raw_body, last_response['content-encoding']) unless raw_body.nil?
|
|
318
|
+
|
|
319
|
+
unless body.nil?
|
|
320
|
+
body = encode_text(body, last_response['content-type'])
|
|
321
|
+
|
|
322
|
+
if decompress_content?
|
|
323
|
+
last_response.delete('content-encoding')
|
|
324
|
+
raw_body = body
|
|
288
325
|
end
|
|
289
326
|
end
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
327
|
+
|
|
328
|
+
Response.new(self, last_response, lambda { parse_response(body) }, body: raw_body)
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def handle_redirection(&block)
|
|
333
|
+
options[:limit] -= 1
|
|
334
|
+
if options[:logger]
|
|
335
|
+
logger = HTTParty::Logger.build(options[:logger], options[:log_level], options[:log_format])
|
|
336
|
+
logger.format(self, last_response)
|
|
296
337
|
end
|
|
338
|
+
self.path = last_response['location']
|
|
339
|
+
self.redirect = true
|
|
340
|
+
if last_response.class == Net::HTTPSeeOther
|
|
341
|
+
unless options[:maintain_method_across_redirects] && options[:resend_on_redirect]
|
|
342
|
+
self.http_method = Net::HTTP::Get
|
|
343
|
+
end
|
|
344
|
+
elsif last_response.code != '307' && last_response.code != '308'
|
|
345
|
+
unless options[:maintain_method_across_redirects]
|
|
346
|
+
self.http_method = Net::HTTP::Get
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
if http_method == Net::HTTP::Get
|
|
350
|
+
clear_body
|
|
351
|
+
end
|
|
352
|
+
capture_cookies(last_response)
|
|
353
|
+
perform(&block)
|
|
297
354
|
end
|
|
298
355
|
|
|
299
356
|
def handle_host_redirection
|
|
300
357
|
check_duplicate_location_header
|
|
301
358
|
redirect_path = options[:uri_adapter].parse(last_response['location']).normalize
|
|
302
|
-
return if redirect_path.relative? || path.host == redirect_path.host
|
|
359
|
+
return if redirect_path.relative? || path.host == redirect_path.host || uri.host == redirect_path.host
|
|
303
360
|
@changed_hosts = true
|
|
304
361
|
end
|
|
305
362
|
|
|
@@ -327,6 +384,14 @@ module HTTParty
|
|
|
327
384
|
parser.call(body, format)
|
|
328
385
|
end
|
|
329
386
|
|
|
387
|
+
# Some Web Application Firewalls reject incoming GET requests that have a body
|
|
388
|
+
# if we redirect, and the resulting verb is GET then we will clear the body that
|
|
389
|
+
# may be left behind from the initiating request
|
|
390
|
+
def clear_body
|
|
391
|
+
options[:body] = nil
|
|
392
|
+
@raw_request.body = nil
|
|
393
|
+
end
|
|
394
|
+
|
|
330
395
|
def capture_cookies(response)
|
|
331
396
|
return unless response['Set-Cookie']
|
|
332
397
|
cookies_hash = HTTParty::CookieHash.new
|
|
@@ -368,6 +433,10 @@ module HTTParty
|
|
|
368
433
|
end
|
|
369
434
|
end
|
|
370
435
|
|
|
436
|
+
def decompress(body, encoding)
|
|
437
|
+
Decompressor.new(body, encoding).decompress
|
|
438
|
+
end
|
|
439
|
+
|
|
371
440
|
def encode_text(text, content_type)
|
|
372
441
|
TextEncoder.new(
|
|
373
442
|
text,
|
|
@@ -375,5 +444,23 @@ module HTTParty
|
|
|
375
444
|
assume_utf16_is_big_endian: assume_utf16_is_big_endian
|
|
376
445
|
).call
|
|
377
446
|
end
|
|
447
|
+
|
|
448
|
+
def validate_uri_safety!(new_uri)
|
|
449
|
+
return if options[:skip_uri_validation]
|
|
450
|
+
|
|
451
|
+
configured_base_uri = options[:base_uri]
|
|
452
|
+
return unless configured_base_uri
|
|
453
|
+
|
|
454
|
+
normalized_base = options[:uri_adapter].parse(
|
|
455
|
+
HTTParty.normalize_base_uri(configured_base_uri)
|
|
456
|
+
)
|
|
457
|
+
|
|
458
|
+
return if new_uri.host == normalized_base.host
|
|
459
|
+
|
|
460
|
+
raise UnsafeURIError,
|
|
461
|
+
"Requested URI '#{new_uri}' has host '#{new_uri.host}' but the " \
|
|
462
|
+
"configured base_uri '#{normalized_base}' has host '#{normalized_base.host}'. " \
|
|
463
|
+
"This request could send credentials to an unintended server."
|
|
464
|
+
end
|
|
378
465
|
end
|
|
379
466
|
end
|
data/lib/httparty/response.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module HTTParty
|
|
2
4
|
class Response < Object
|
|
3
5
|
def self.underscore(string)
|
|
@@ -49,14 +51,14 @@ module HTTParty
|
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def inspect
|
|
52
|
-
inspect_id = ::Kernel::format
|
|
54
|
+
inspect_id = ::Kernel::format '%x', (object_id * 2)
|
|
53
55
|
%(#<#{self.class}:0x#{inspect_id} parsed_response=#{parsed_response.inspect}, @response=#{response.inspect}, @headers=#{headers.inspect}>)
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
CODES_TO_OBJ = ::Net::HTTPResponse::CODE_CLASS_TO_OBJ.merge ::Net::HTTPResponse::CODE_TO_OBJ
|
|
57
59
|
|
|
58
60
|
CODES_TO_OBJ.each do |response_code, klass|
|
|
59
|
-
name = klass.name.sub(
|
|
61
|
+
name = klass.name.sub('Net::HTTP', '')
|
|
60
62
|
name = "#{underscore(name)}?".to_sym
|
|
61
63
|
|
|
62
64
|
define_method(name) do
|
|
@@ -65,12 +67,12 @@ module HTTParty
|
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
# Support old multiple_choice? method from pre 2.0.0 era.
|
|
68
|
-
if ::
|
|
70
|
+
if ::RUBY_PLATFORM != 'java'
|
|
69
71
|
alias_method :multiple_choice?, :multiple_choices?
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
# Support old status codes method from pre 2.6.0 era.
|
|
73
|
-
if ::
|
|
75
|
+
if ::RUBY_PLATFORM != 'java'
|
|
74
76
|
alias_method :gateway_time_out?, :gateway_timeout?
|
|
75
77
|
alias_method :request_entity_too_large?, :payload_too_large?
|
|
76
78
|
alias_method :request_time_out?, :request_timeout?
|
|
@@ -131,7 +133,7 @@ module HTTParty
|
|
|
131
133
|
end
|
|
132
134
|
|
|
133
135
|
def throw_exception
|
|
134
|
-
if @request.options[:raise_on]
|
|
136
|
+
if @request.options[:raise_on].to_a.detect { |c| code.to_s.match(/#{c.to_s}/) }
|
|
135
137
|
::Kernel.raise ::HTTParty::ResponseError.new(@response), "Code #{code} - #{body}"
|
|
136
138
|
end
|
|
137
139
|
end
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module HTTParty
|
|
2
4
|
class TextEncoder
|
|
3
5
|
attr_reader :text, :content_type, :assume_utf16_is_big_endian
|
|
4
6
|
|
|
5
7
|
def initialize(text, assume_utf16_is_big_endian: true, content_type: nil)
|
|
6
|
-
@text = text
|
|
8
|
+
@text = +text
|
|
7
9
|
@content_type = content_type
|
|
8
10
|
@assume_utf16_is_big_endian = assume_utf16_is_big_endian
|
|
9
11
|
end
|
|
@@ -33,16 +35,16 @@ module HTTParty
|
|
|
33
35
|
def encode_utf_16
|
|
34
36
|
if text.bytesize >= 2
|
|
35
37
|
if text.getbyte(0) == 0xFF && text.getbyte(1) == 0xFE
|
|
36
|
-
return text.force_encoding(
|
|
38
|
+
return text.force_encoding('UTF-16LE')
|
|
37
39
|
elsif text.getbyte(0) == 0xFE && text.getbyte(1) == 0xFF
|
|
38
|
-
return text.force_encoding(
|
|
40
|
+
return text.force_encoding('UTF-16BE')
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
if assume_utf16_is_big_endian # option
|
|
43
|
-
text.force_encoding(
|
|
45
|
+
text.force_encoding('UTF-16BE')
|
|
44
46
|
else
|
|
45
|
-
text.force_encoding(
|
|
47
|
+
text.force_encoding('UTF-16LE')
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
50
|
|
data/lib/httparty/utils.rb
CHANGED
data/lib/httparty/version.rb
CHANGED
data/lib/httparty.rb
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'pathname'
|
|
2
4
|
require 'net/http'
|
|
3
|
-
require 'net/https'
|
|
4
5
|
require 'uri'
|
|
5
|
-
require 'zlib'
|
|
6
|
-
require 'multi_xml'
|
|
7
|
-
require 'mime/types'
|
|
8
|
-
require 'json'
|
|
9
|
-
require 'csv'
|
|
10
6
|
|
|
11
7
|
require 'httparty/module_inheritable_attributes'
|
|
12
8
|
require 'httparty/cookie_hash'
|
|
@@ -16,6 +12,7 @@ require 'httparty/connection_adapter'
|
|
|
16
12
|
require 'httparty/logger/logger'
|
|
17
13
|
require 'httparty/request/body'
|
|
18
14
|
require 'httparty/response_fragment'
|
|
15
|
+
require 'httparty/decompressor'
|
|
19
16
|
require 'httparty/text_encoder'
|
|
20
17
|
require 'httparty/headers_processor'
|
|
21
18
|
|
|
@@ -26,8 +23,8 @@ module HTTParty
|
|
|
26
23
|
base.send :include, ModuleInheritableAttributes
|
|
27
24
|
base.send(:mattr_inheritable, :default_options)
|
|
28
25
|
base.send(:mattr_inheritable, :default_cookies)
|
|
29
|
-
base.instance_variable_set(
|
|
30
|
-
base.instance_variable_set(
|
|
26
|
+
base.instance_variable_set(:@default_options, {})
|
|
27
|
+
base.instance_variable_set(:@default_cookies, CookieHash.new)
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
# == Common Request Options
|
|
@@ -65,6 +62,16 @@ module HTTParty
|
|
|
65
62
|
# * :+ssl_ca_path+: see HTTParty::ClassMethods.ssl_ca_path.
|
|
66
63
|
|
|
67
64
|
module ClassMethods
|
|
65
|
+
# Turns on or off the foul option.
|
|
66
|
+
#
|
|
67
|
+
# class Foo
|
|
68
|
+
# include HTTParty
|
|
69
|
+
# foul true
|
|
70
|
+
# end
|
|
71
|
+
def foul(bool)
|
|
72
|
+
default_options[:foul] = bool
|
|
73
|
+
end
|
|
74
|
+
|
|
68
75
|
# Turns on logging
|
|
69
76
|
#
|
|
70
77
|
# class Foo
|
|
@@ -81,7 +88,7 @@ module HTTParty
|
|
|
81
88
|
#
|
|
82
89
|
# class Foo
|
|
83
90
|
# include HTTParty
|
|
84
|
-
# raise_on [404, 500]
|
|
91
|
+
# raise_on [404, 500, '5[0-9]*']
|
|
85
92
|
# end
|
|
86
93
|
def raise_on(codes = [])
|
|
87
94
|
default_options[:raise_on] = *codes
|
|
@@ -399,6 +406,22 @@ module HTTParty
|
|
|
399
406
|
default_options[:ssl_version] = version
|
|
400
407
|
end
|
|
401
408
|
|
|
409
|
+
# Deactivate automatic decompression of the response body.
|
|
410
|
+
# This will require you to explicitly handle body decompression
|
|
411
|
+
# by inspecting the Content-Encoding response header.
|
|
412
|
+
#
|
|
413
|
+
# Refer to docs/README.md "HTTP Compression" section for
|
|
414
|
+
# further details.
|
|
415
|
+
#
|
|
416
|
+
# @example
|
|
417
|
+
# class Foo
|
|
418
|
+
# include HTTParty
|
|
419
|
+
# skip_decompression
|
|
420
|
+
# end
|
|
421
|
+
def skip_decompression(value = true)
|
|
422
|
+
default_options[:skip_decompression] = !!value
|
|
423
|
+
end
|
|
424
|
+
|
|
402
425
|
# Allows setting of SSL ciphers to use. This only works in Ruby 1.9+.
|
|
403
426
|
# You can get a list of valid specific ciphers from OpenSSL::Cipher.ciphers.
|
|
404
427
|
# You also can specify a cipher suite here, listed here at openssl.org:
|
|
@@ -573,6 +596,13 @@ module HTTParty
|
|
|
573
596
|
perform_request Net::HTTP::Unlock, path, options, &block
|
|
574
597
|
end
|
|
575
598
|
|
|
599
|
+
def build_request(http_method, path, options = {})
|
|
600
|
+
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
|
|
601
|
+
HeadersProcessor.new(headers, options).call
|
|
602
|
+
process_cookies(options)
|
|
603
|
+
Request.new(http_method, path, options)
|
|
604
|
+
end
|
|
605
|
+
|
|
576
606
|
attr_reader :default_options
|
|
577
607
|
|
|
578
608
|
private
|
|
@@ -588,16 +618,13 @@ module HTTParty
|
|
|
588
618
|
end
|
|
589
619
|
|
|
590
620
|
def perform_request(http_method, path, options, &block) #:nodoc:
|
|
591
|
-
|
|
592
|
-
HeadersProcessor.new(headers, options).call
|
|
593
|
-
process_cookies(options)
|
|
594
|
-
Request.new(http_method, path, options).perform(&block)
|
|
621
|
+
build_request(http_method, path, options).perform(&block)
|
|
595
622
|
end
|
|
596
623
|
|
|
597
624
|
def process_cookies(options) #:nodoc:
|
|
598
625
|
return unless options[:cookies] || default_cookies.any?
|
|
599
626
|
options[:headers] ||= headers.dup
|
|
600
|
-
options[:headers][
|
|
627
|
+
options[:headers]['cookie'] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
|
|
601
628
|
end
|
|
602
629
|
|
|
603
630
|
def validate_format
|
|
@@ -658,6 +685,10 @@ module HTTParty
|
|
|
658
685
|
def self.options(*args, &block)
|
|
659
686
|
Basement.options(*args, &block)
|
|
660
687
|
end
|
|
688
|
+
|
|
689
|
+
def self.build_request(*args, &block)
|
|
690
|
+
Basement.build_request(*args, &block)
|
|
691
|
+
end
|
|
661
692
|
end
|
|
662
693
|
|
|
663
694
|
require 'httparty/hash_conversions'
|
data/script/release
CHANGED
|
@@ -18,9 +18,9 @@ gem_name=httparty
|
|
|
18
18
|
rm -rf $gem_name-*.gem
|
|
19
19
|
gem build -q $gem_name.gemspec
|
|
20
20
|
|
|
21
|
-
# Make sure we're on the
|
|
22
|
-
(git branch | grep -q '*
|
|
23
|
-
echo "Only release from the
|
|
21
|
+
# Make sure we're on the main branch.
|
|
22
|
+
(git branch | grep -q '* main') || {
|
|
23
|
+
echo "Only release from the main branch."
|
|
24
24
|
exit 1
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -39,4 +39,4 @@ git fetch -t origin
|
|
|
39
39
|
|
|
40
40
|
# Tag it and bag it.
|
|
41
41
|
gem push $gem_name-*.gem && git tag "$tag" &&
|
|
42
|
-
git push origin
|
|
42
|
+
git push origin main && git push origin "$tag"
|
metadata
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: httparty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.24.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Nunemaker
|
|
8
8
|
- Sandro Turriate
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2025-12-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: csv
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ">="
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '0'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '0'
|
|
14
28
|
- !ruby/object:Gem::Dependency
|
|
15
29
|
name: multi_xml
|
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -26,19 +40,19 @@ dependencies:
|
|
|
26
40
|
- !ruby/object:Gem::Version
|
|
27
41
|
version: 0.5.2
|
|
28
42
|
- !ruby/object:Gem::Dependency
|
|
29
|
-
name:
|
|
43
|
+
name: mini_mime
|
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
|
31
45
|
requirements:
|
|
32
|
-
- - "
|
|
46
|
+
- - ">="
|
|
33
47
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
48
|
+
version: 1.0.0
|
|
35
49
|
type: :runtime
|
|
36
50
|
prerelease: false
|
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
52
|
requirements:
|
|
39
|
-
- - "
|
|
53
|
+
- - ">="
|
|
40
54
|
- !ruby/object:Gem::Version
|
|
41
|
-
version:
|
|
55
|
+
version: 1.0.0
|
|
42
56
|
description: Makes http fun! Also, makes consuming restful web services dead easy.
|
|
43
57
|
email:
|
|
44
58
|
- nunemaker@gmail.com
|
|
@@ -48,11 +62,11 @@ extensions: []
|
|
|
48
62
|
extra_rdoc_files: []
|
|
49
63
|
files:
|
|
50
64
|
- ".editorconfig"
|
|
65
|
+
- ".github/dependabot.yml"
|
|
66
|
+
- ".github/workflows/ci.yml"
|
|
51
67
|
- ".gitignore"
|
|
52
68
|
- ".rubocop.yml"
|
|
53
69
|
- ".rubocop_todo.yml"
|
|
54
|
-
- ".simplecov"
|
|
55
|
-
- ".travis.yml"
|
|
56
70
|
- CONTRIBUTING.md
|
|
57
71
|
- Changelog.md
|
|
58
72
|
- Gemfile
|
|
@@ -72,10 +86,12 @@ files:
|
|
|
72
86
|
- examples/delicious.rb
|
|
73
87
|
- examples/google.rb
|
|
74
88
|
- examples/headers_and_user_agents.rb
|
|
89
|
+
- examples/idn.rb
|
|
75
90
|
- examples/logging.rb
|
|
76
91
|
- examples/microsoft_graph.rb
|
|
77
92
|
- examples/multipart.rb
|
|
78
93
|
- examples/nokogiri_html_parser.rb
|
|
94
|
+
- examples/party_foul_mode.rb
|
|
79
95
|
- examples/peer_cert.rb
|
|
80
96
|
- examples/rescue_json.rb
|
|
81
97
|
- examples/rubyurl.rb
|
|
@@ -88,6 +104,7 @@ files:
|
|
|
88
104
|
- lib/httparty.rb
|
|
89
105
|
- lib/httparty/connection_adapter.rb
|
|
90
106
|
- lib/httparty/cookie_hash.rb
|
|
107
|
+
- lib/httparty/decompressor.rb
|
|
91
108
|
- lib/httparty/exceptions.rb
|
|
92
109
|
- lib/httparty/hash_conversions.rb
|
|
93
110
|
- lib/httparty/headers_processor.rb
|
|
@@ -101,6 +118,7 @@ files:
|
|
|
101
118
|
- lib/httparty/request.rb
|
|
102
119
|
- lib/httparty/request/body.rb
|
|
103
120
|
- lib/httparty/request/multipart_boundary.rb
|
|
121
|
+
- lib/httparty/request/streaming_multipart_body.rb
|
|
104
122
|
- lib/httparty/response.rb
|
|
105
123
|
- lib/httparty/response/headers.rb
|
|
106
124
|
- lib/httparty/response_fragment.rb
|
|
@@ -113,7 +131,8 @@ files:
|
|
|
113
131
|
homepage: https://github.com/jnunemaker/httparty
|
|
114
132
|
licenses:
|
|
115
133
|
- MIT
|
|
116
|
-
metadata:
|
|
134
|
+
metadata:
|
|
135
|
+
changelog_uri: https://github.com/jnunemaker/httparty/releases
|
|
117
136
|
post_install_message: When you HTTParty, you must party hard!
|
|
118
137
|
rdoc_options: []
|
|
119
138
|
require_paths:
|
|
@@ -122,15 +141,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
122
141
|
requirements:
|
|
123
142
|
- - ">="
|
|
124
143
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: 2.
|
|
144
|
+
version: 2.7.0
|
|
126
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
146
|
requirements:
|
|
128
147
|
- - ">="
|
|
129
148
|
- !ruby/object:Gem::Version
|
|
130
149
|
version: '0'
|
|
131
150
|
requirements: []
|
|
132
|
-
rubygems_version: 3.
|
|
133
|
-
signing_key:
|
|
151
|
+
rubygems_version: 3.3.7
|
|
152
|
+
signing_key:
|
|
134
153
|
specification_version: 4
|
|
135
154
|
summary: Makes http fun! Also, makes consuming restful web services dead easy.
|
|
136
155
|
test_files: []
|
data/.simplecov
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
SimpleCov.start "test_frameworks"
|