httparty 0.24.4 → 0.25.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dd88885a49c925e66a28cb979491ade60280598f97c1051a07624e5cbbf7ce5
4
- data.tar.gz: 3ab8ceca964d91507981c5508f994105030727ed2c347262ae8aa353481432ce
3
+ metadata.gz: 6fcd7a36016d83ccd756fbb81ee2614828d7764255e0e51ee9fe6a19fb9fe400
4
+ data.tar.gz: 3c7132cec52abc3f9909269787ab37a358ed960aecb2f79fa4ef013614399759
5
5
  SHA512:
6
- metadata.gz: b29fc69f69247a3621ada6b919c9d420892d5ecc4c1ca474bf78a59f9c324a7e772c85d4f5374f973dc606a76033e5ad741cfc67decf8b8561459f974095b2ef
7
- data.tar.gz: 7fbb9fefc822c17e33d85bd6452a0a17a90dc5a0781abea2df753a812ff80fd2106425c29ed0b3fe2d85d2fb32d89b48b7976f553952bc4c74b570fdebc79990
6
+ metadata.gz: 6ebb92691c60a4c2799080667be437ce3b298fda670ff65fa8b27d20488b8747a8dc37f44d5f58b65e4d59324a41fa44dfa35b54f05fd26e9b474fc12b150a0f
7
+ data.tar.gz: 0d760a50dce828591aa5c49fbcbc99c56730bcbae07caa5e1ce818a6fd3b1c5fc36c815115bb5774e3355bf2924b5d357525bb55fd4c6cfcdd9e0abf34a088a8
data/docs/README.md CHANGED
@@ -147,7 +147,7 @@ class Client
147
147
  def self.fetch
148
148
  get("/resources", verify: false)
149
149
  # You can also use something like:
150
- # get("resources", verify_peer: false)
150
+ # get("/resources", verify_peer: false)
151
151
  end
152
152
  end
153
153
  ```
data/httparty.gemspec CHANGED
@@ -24,7 +24,9 @@ Gem::Specification.new do |s|
24
24
  s.post_install_message = "When you HTTParty, you must party hard!"
25
25
 
26
26
  all_files = `git ls-files`.split("\n")
27
- test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ # Separate pathspecs, not {test,spec,features}/*: backticks run /bin/sh,
28
+ # and dash (the /bin/sh on Debian and Ubuntu) doesn't expand braces.
29
+ test_files = `git ls-files -- test spec features`.split("\n")
28
30
  dev_files = `git ls-files -- .github Gemfile Guardfile '.rubocop*' script`.split("\n")
29
31
 
30
32
  s.files = all_files - test_files - dev_files
@@ -17,7 +17,7 @@ module HTTParty
17
17
  # def connection
18
18
  # puts uri
19
19
  # puts options
20
- # Net::HTTP.new(uri)
20
+ # super
21
21
  # end
22
22
  # end
23
23
  #
@@ -25,12 +25,12 @@ module HTTParty
25
25
  # class CountingConnectionAdapter < HTTParty::ConnectionAdapter
26
26
  # @@count = 0
27
27
  #
28
- # self.count
28
+ # def self.count
29
29
  # @@count
30
30
  # end
31
31
  #
32
32
  # def connection
33
- # self.count += 1
33
+ # @@count += 1
34
34
  # super
35
35
  # end
36
36
  # end
@@ -11,6 +11,7 @@ module HTTParty
11
11
 
12
12
  def call
13
13
  return unless options[:headers]
14
+ raise ArgumentError, ':headers must be a hash' unless options[:headers].respond_to?(:to_hash)
14
15
 
15
16
  options[:headers] = headers.merge(options[:headers]) if headers.any?
16
17
  options[:headers] = Utils.stringify_keys(process_dynamic_headers)
@@ -4,6 +4,7 @@ module HTTParty
4
4
  module Logger
5
5
  class ApacheFormatter #:nodoc:
6
6
  TAG_NAME = HTTParty.name
7
+ LOG_ESCAPES = /[[:cntrl:]"\\]/
7
8
 
8
9
  attr_accessor :level, :logger
9
10
 
@@ -24,7 +25,7 @@ module HTTParty
24
25
  attr_reader :request, :response
25
26
 
26
27
  def message
27
- "[#{TAG_NAME}] [#{current_time}] #{response.code} \"#{http_method} #{path}\" #{content_length || '-'} "
28
+ "[#{TAG_NAME}] [#{current_time}] #{response.code} \"#{http_method} #{sanitize(path)}\" #{content_length || '-'} "
28
29
  end
29
30
 
30
31
  def current_time
@@ -39,6 +40,18 @@ module HTTParty
39
40
  request.path.to_s
40
41
  end
41
42
 
43
+ # Escape the request path the way Apache's own access log does: control
44
+ # characters (e.g. CR/LF) become \xhh, and " and \ get a backslash. A
45
+ # crafted path then can't split or forge a log line (CWE-117), and the
46
+ # attempt stays visible. This matters with a permissive URI adapter
47
+ # such as Addressable; the default URI adapter rejects these characters.
48
+ # Invalid bytes are scrubbed first so the regex can't raise.
49
+ def sanitize(value)
50
+ value.to_s.scrub.gsub(LOG_ESCAPES) do |char|
51
+ char == '"' || char == '\\' ? "\\#{char}" : '\\x%02x' % char.ord
52
+ end
53
+ end
54
+
42
55
  def content_length
43
56
  response.respond_to?(:headers) ? response.headers['Content-Length'] : response['Content-Length']
44
57
  end
@@ -41,7 +41,7 @@ module HTTParty
41
41
  def log_response
42
42
  log IN, "HTTP/#{response.http_version} #{response.code}"
43
43
  log_response_headers
44
- log IN, "\n#{response.body}"
44
+ log IN, "\n", response.body
45
45
  log IN
46
46
  end
47
47
 
@@ -53,7 +53,7 @@ module HTTParty
53
53
  request.path.to_s
54
54
  end
55
55
 
56
- log OUT, "#{http_method} #{uri}"
56
+ log OUT, http_method, ' ', uri
57
57
  end
58
58
 
59
59
  def log_headers
@@ -74,28 +74,39 @@ module HTTParty
74
74
  def log_response_headers
75
75
  headers = response.respond_to?(:headers) ? response.headers : response
76
76
  response.each_header do |response_header|
77
- log IN, "#{response_header.capitalize}: #{headers[response_header]}"
77
+ log IN, response_header.capitalize, ': ', headers[response_header]
78
78
  end
79
79
  end
80
80
 
81
81
  def log_hash(hash)
82
- hash.each { |k, v| log(OUT, "#{k}: #{v}") }
82
+ hash.each { |k, v| log(OUT, k, ': ', v) }
83
83
  end
84
84
 
85
- def log(direction, line = '')
86
- messages << "[#{TAG_NAME}] [#{current_time}] #{direction} #{encode_log(line)}"
85
+ # Each part is converted before it is joined, so values in mixed
86
+ # encodings can't raise and fail the request just to write a log line.
87
+ def log(direction, *parts)
88
+ line = parts.map { |part| encode_log(part) }.join
89
+ messages << "[#{TAG_NAME}] [#{current_time}] #{direction} #{line}"
87
90
  end
88
91
 
89
- # Logger lines are joined later, which raises if they mix encodings (a
90
- # binary body next to a non-ASCII header). Binary is relabeled as UTF-8;
91
- # other charsets are converted so their text survives.
92
- def encode_log(line)
93
- text = line.to_s
94
- if text.encoding == Encoding::BINARY
95
- text.dup.force_encoding(Encoding::UTF_8).scrub
92
+ # Binary and broken UTF-8 are relabeled and scrubbed so readable text
93
+ # survives; other charsets are converted.
94
+ def encode_log(part)
95
+ text = part.to_s
96
+ return text if text.encoding == Encoding::UTF_8 && text.valid_encoding?
97
+
98
+ if text.encoding == Encoding::BINARY || text.encoding == Encoding::UTF_8
99
+ relabel_utf8(text)
96
100
  else
97
101
  text.encode(Encoding::UTF_8, invalid: :replace, undef: :replace)
98
102
  end
103
+ rescue Encoding::ConverterNotFoundError
104
+ relabel_utf8(text)
105
+ end
106
+
107
+ def relabel_utf8(text)
108
+ utf8 = text.dup.force_encoding(Encoding::UTF_8)
109
+ utf8.valid_encoding? ? utf8 : utf8.scrub
99
110
  end
100
111
 
101
112
  def current_time
@@ -91,7 +91,9 @@ module HTTParty
91
91
 
92
92
  def normalize_query(query)
93
93
  if query_string_normalizer
94
- query_string_normalizer.call(query)
94
+ # Normalizers may return an array of pairs, which the query string joins with '&'
95
+ normalized = query_string_normalizer.call(query)
96
+ normalized.respond_to?(:to_ary) ? normalized.to_ary.join('&') : normalized
95
97
  else
96
98
  HashConversions.to_params(query)
97
99
  end
@@ -20,6 +20,9 @@ module HTTParty
20
20
  ]
21
21
 
22
22
  SupportedURISchemes = ['http', 'https', 'webcal', nil]
23
+ DEFAULT_PORTS = { 'http' => 80, 'https' => 443 }.freeze
24
+ # Headers that describe a request body, and so are dropped along with it
25
+ CONTENT_HEADERS = %w[content-encoding content-language content-length content-location content-type transfer-encoding].freeze
23
26
 
24
27
  NON_RAILS_QUERY_STRING_NORMALIZER = proc do |query|
25
28
  Array(query).sort_by { |a| a[0].to_s }.map do |key, value|
@@ -60,6 +63,7 @@ module HTTParty
60
63
 
61
64
  def initialize(http_method, path, o = {})
62
65
  @changed_hosts = false
66
+ @cross_origin_redirect = false
63
67
  @credentials_sent = false
64
68
 
65
69
  self.http_method = http_method
@@ -78,15 +82,18 @@ module HTTParty
78
82
 
79
83
  def path=(uri)
80
84
  uri_adapter = options[:uri_adapter]
81
- @slash_added_to_empty_path = false
82
85
 
83
86
  @path = if uri.is_a?(uri_adapter)
84
87
  uri
85
- elsif String.try_convert(uri)
86
- parsed_uri = uri_adapter.parse(uri)
87
- normalized_uri = parsed_uri.normalize
88
- @slash_added_to_empty_path = empty_path_reference?(parsed_uri) && normalized_uri.path == '/'
89
- normalized_uri
88
+ elsif (uri_str = String.try_convert(uri))
89
+ # Normalizing an empty path ("", "?query" or "#fragment") with the
90
+ # default URI adapter turns it into "/", which appends an unwanted
91
+ # trailing slash to the base_uri path (breaking e.g. SOAP endpoints).
92
+ # Such a reference means the base_uri itself (RFC 3986 section 5.2.2),
93
+ # so leave it alone and let the uri adapter normalize everything else.
94
+ # See https://github.com/jnunemaker/httparty/issues/742
95
+ parsed_uri = uri_adapter.parse(uri_str)
96
+ empty_path_reference?(parsed_uri) ? parsed_uri : parsed_uri.normalize
90
97
  else
91
98
  raise ArgumentError,
92
99
  "bad argument (expected #{uri_adapter} object or URI string)"
@@ -102,18 +109,18 @@ module HTTParty
102
109
  end
103
110
 
104
111
  def uri
105
- if redirect && path.relative? && path.path[0] != '/'
106
- last_uri_host = @last_uri.path.gsub(/[^\/]+$/, '')
107
-
108
- path.path = "/#{path.path}" if last_uri_host[-1] != '/'
109
- path.path = "#{last_uri_host}#{path.path}"
112
+ # Resolve a relative redirect Location ("baz", "../baz", "?page=2", "")
113
+ # against the URL that redirected (RFC 3986 section 5.2). Keep it as an
114
+ # absolute path so later calls resolve it to the same URL. A Location
115
+ # with a host is used as given below.
116
+ if redirect && path.relative? && path.host.nil?
117
+ @path = options[:uri_adapter].parse(request_uri((@last_uri + path).normalize))
110
118
  end
111
119
 
112
120
  if path.relative? && path.host
113
121
  new_uri = options[:uri_adapter].parse("#{@last_uri.scheme}:#{path}").normalize
114
122
  elsif path.relative?
115
123
  new_uri = options[:uri_adapter].parse("#{base_uri}#{path}").normalize
116
- warn_about_empty_path_trailing_slash(new_uri) if !redirect && @slash_added_to_empty_path && new_uri.path != '/'
117
124
  else
118
125
  new_uri = path.clone
119
126
  end
@@ -185,7 +192,7 @@ module HTTParty
185
192
  end
186
193
 
187
194
  def handle_unauthorized(&block)
188
- return unless digest_auth? && response_unauthorized? && response_has_digest_auth_challenge?
195
+ return unless digest_auth? && send_authorization_header? && response_unauthorized? && response_has_digest_auth_challenge?
189
196
  return if @credentials_sent
190
197
  @credentials_sent = true
191
198
  perform(&block)
@@ -233,6 +240,10 @@ module HTTParty
233
240
  def setup_raw_request
234
241
  if options[:headers].respond_to?(:to_hash)
235
242
  headers_hash = options[:headers].to_hash
243
+ unless send_authorization_header?
244
+ # Header names are case-insensitive, and reject leaves the caller's hash alone
245
+ headers_hash = headers_hash.reject { |name, _| name.to_s.casecmp?('authorization') }
246
+ end
236
247
  else
237
248
  headers_hash = nil
238
249
  end
@@ -269,7 +280,7 @@ module HTTParty
269
280
  @raw_request.basic_auth(username, password)
270
281
  @credentials_sent = true
271
282
  end
272
- setup_digest_auth if digest_auth? && response_unauthorized? && response_has_digest_auth_challenge?
283
+ setup_digest_auth if digest_auth? && send_authorization_header? && response_unauthorized? && response_has_digest_auth_challenge?
273
284
  end
274
285
 
275
286
  def digest_auth?
@@ -338,10 +349,14 @@ module HTTParty
338
349
  logger = HTTParty::Logger.build(options[:logger], options[:log_level], options[:log_format])
339
350
  logger.format(self, last_response)
340
351
  end
341
- self.path = last_response['location']
352
+ # A relative Location is resolved against the current URL in #uri, so
353
+ # it isn't normalized first: Addressable would drop the "../" in it.
354
+ location = options[:uri_adapter].parse(last_response['location'])
355
+ self.path = location.relative? && location.host.nil? ? location : location.normalize
342
356
  self.redirect = true
343
357
  if last_response.class == Net::HTTPSeeOther
344
- unless options[:maintain_method_across_redirects] && options[:resend_on_redirect]
358
+ # A 303 turns the request into a GET, but a HEAD stays a HEAD (RFC 9110)
359
+ unless options[:maintain_method_across_redirects] && (options[:resend_on_redirect] || http_method == Net::HTTP::Head)
345
360
  self.http_method = Net::HTTP::Get
346
361
  end
347
362
  elsif last_response.code != '307' && last_response.code != '308'
@@ -352,15 +367,36 @@ module HTTParty
352
367
  if http_method == Net::HTTP::Get
353
368
  clear_body
354
369
  end
355
- capture_cookies(last_response)
370
+ # Cookies stay with the origin they came from. HTTParty doesn't track the
371
+ # Set-Cookie Domain attribute, so a redirect to another origin gets none
372
+ # of them; that origin's own Set-Cookie cookies are collected from here on.
373
+ @cross_origin_redirect ? drop_cookies : capture_cookies(last_response)
356
374
  perform(&block)
357
375
  end
358
376
 
359
377
  def handle_host_redirection
360
378
  check_duplicate_location_header
361
379
  redirect_path = options[:uri_adapter].parse(last_response['location']).normalize
362
- return if redirect_path.relative? || path.host == redirect_path.host || uri.host == redirect_path.host
363
- @changed_hosts = true
380
+ # A Location without a host ("/x", "../x", "?a") stays on the same origin.
381
+ # A scheme-relative one ("//other.example.com/x") has a host to compare.
382
+ @cross_origin_redirect = !(redirect_path.relative? && redirect_path.host.nil?) &&
383
+ cross_origin_redirect?(@last_uri, redirect_path)
384
+ @changed_hosts = true if @cross_origin_redirect
385
+ end
386
+
387
+ # Credentials only follow a redirect to the same scheme, host and port, as
388
+ # in curl and Python requests. An http -> https upgrade on the default
389
+ # ports keeps them, and once dropped they stay dropped for the request.
390
+ def cross_origin_redirect?(from, to)
391
+ return true unless from.host.to_s.casecmp?(to.host.to_s)
392
+
393
+ to_scheme = (to.scheme || from.scheme).to_s.downcase
394
+ from_scheme = from.scheme.to_s.downcase
395
+ from_port = from.port || DEFAULT_PORTS[from_scheme]
396
+ to_port = to.port || DEFAULT_PORTS[to_scheme]
397
+ return false if from_scheme == to_scheme && from_port == to_port
398
+
399
+ !(from_scheme == 'http' && from_port == 80 && to_scheme == 'https' && to_port == 443)
364
400
  end
365
401
 
366
402
  def check_duplicate_location_header
@@ -388,21 +424,36 @@ module HTTParty
388
424
  end
389
425
 
390
426
  # Some Web Application Firewalls reject incoming GET requests that have a body
391
- # if we redirect, and the resulting verb is GET then we will clear the body that
392
- # may be left behind from the initiating request
427
+ # if we redirect, and the resulting verb is GET then we will clear the body (or
428
+ # body_stream) that may be left behind from the initiating request, along with
429
+ # the header fields that described it (RFC 9110, section 15.4)
393
430
  def clear_body
394
431
  options[:body] = nil
432
+ options[:body_stream] = nil
395
433
  @raw_request.body = nil
434
+ return unless options[:headers].respond_to?(:to_hash)
435
+
436
+ options[:headers] = options[:headers].to_hash.reject do |name, _|
437
+ CONTENT_HEADERS.include?(name.to_s.downcase)
438
+ end
396
439
  end
397
440
 
398
441
  def capture_cookies(response)
399
442
  return unless response['Set-Cookie']
443
+ headers = options[:headers].respond_to?(:to_hash) ? options[:headers].to_hash : {}
444
+ # Class and request cookies are stored as "cookie", so match any case
445
+ cookie_names = headers.keys.select { |name| name.to_s.casecmp?('cookie') }
400
446
  cookies_hash = HTTParty::CookieHash.new
401
- cookies_hash.add_cookies(options[:headers].to_hash['Cookie']) if options[:headers] && options[:headers].to_hash['Cookie']
447
+ cookie_names.each { |name| cookies_hash.add_cookies(headers[name]) }
402
448
  response.get_fields('Set-Cookie').each { |cookie| cookies_hash.add_cookies(cookie) }
403
449
 
404
- options[:headers] ||= {}
405
- options[:headers]['Cookie'] = cookies_hash.to_cookie_string
450
+ options[:headers] = headers.reject { |name, _| cookie_names.include?(name) }
451
+ .merge('Cookie' => cookies_hash.to_cookie_string)
452
+ end
453
+
454
+ def drop_cookies
455
+ return unless options[:headers].respond_to?(:to_hash)
456
+ options[:headers] = options[:headers].to_hash.reject { |name, _| name.to_s.casecmp?('cookie') }
406
457
  end
407
458
 
408
459
  # Uses the HTTP Content-Type header to determine the format of the
@@ -416,7 +467,7 @@ module HTTParty
416
467
 
417
468
  def validate
418
469
  raise HTTParty::RedirectionTooDeep.new(last_response), 'HTTP redirects too deep' if options[:limit].to_i <= 0
419
- raise ArgumentError, 'only get, post, patch, put, delete, head, and options methods are supported' unless SupportedHTTPMethods.include?(http_method)
470
+ raise ArgumentError, "only #{SupportedHTTPMethods.map { |m| m::METHOD.downcase }.join(', ')} methods are supported" unless SupportedHTTPMethods.include?(http_method)
420
471
  raise ArgumentError, ':headers must be a hash' if options[:headers] && !options[:headers].respond_to?(:to_hash)
421
472
  raise ArgumentError, 'only one authentication method, :basic_auth or :digest_auth may be used at a time' if options[:basic_auth] && options[:digest_auth]
422
473
  raise ArgumentError, ':basic_auth must be a hash' if options[:basic_auth] && !options[:basic_auth].respond_to?(:to_hash)
@@ -454,20 +505,6 @@ module HTTParty
454
505
  uri.scheme.nil? && uri.host.nil? && uri.path.to_s.empty?
455
506
  end
456
507
 
457
- def warn_about_empty_path_trailing_slash(new_uri)
458
- @slash_added_to_empty_path = false # warn once per request
459
- trace_line = caller.reject { |line| line.include?('httparty') }.first
460
- warning = "[DEPRECATION] HTTParty added a trailing slash to the request path " \
461
- "(#{new_uri.path}) because the path passed to the request was empty. " \
462
- "In HTTParty 0.25, an empty, query-only (\"?a=1\") or fragment-only path " \
463
- "will request the base_uri path as-is, without a trailing slash, matching " \
464
- "RFC 3986 and other HTTP clients. To keep the trailing slash, pass \"/\" as the path. " \
465
- "For more info refer to: https://github.com/jnunemaker/httparty/issues/742\n" \
466
- "#{trace_line}"
467
-
468
- warn(warning)
469
- end
470
-
471
508
  def validate_uri_safety!(new_uri)
472
509
  return if options[:skip_uri_validation]
473
510
 
@@ -53,7 +53,7 @@ module HTTParty
53
53
 
54
54
  def inspect
55
55
  inspect_id = ::Kernel::format '%x', (object_id * 2)
56
- %(#<#{self.class}:0x#{inspect_id} parsed_response=#{parsed_response.inspect}, @response=#{response.inspect}, @headers=#{headers.inspect}>)
56
+ %(#<#{self.class}:0x#{inspect_id} #{inspect_parsed_response}, @response=#{response.inspect}, @headers=#{headers.inspect}>)
57
57
  end
58
58
 
59
59
  CODES_TO_OBJ = ::Net::HTTPResponse::CODE_CLASS_TO_OBJ.merge ::Net::HTTPResponse::CODE_TO_OBJ
@@ -95,8 +95,12 @@ module HTTParty
95
95
  end
96
96
 
97
97
  def pretty_print(pp)
98
- if !parsed_response.nil? && parsed_response.respond_to?(:pretty_print)
99
- parsed_response.pretty_print(pp)
98
+ parsed = parsed_response
99
+ rescue StandardError
100
+ super
101
+ else
102
+ if !parsed.nil? && parsed.respond_to?(:pretty_print)
103
+ parsed.pretty_print(pp)
100
104
  else
101
105
  super
102
106
  end
@@ -146,6 +150,13 @@ module HTTParty
146
150
 
147
151
  private
148
152
 
153
+ # Debugging output must not raise, so show a parse error and the raw body.
154
+ def inspect_parsed_response
155
+ "parsed_response=#{parsed_response.inspect}"
156
+ rescue StandardError => e
157
+ "parsed_response=#<#{e.class}: #{e.message.inspect}>, body=#{body.inspect}"
158
+ end
159
+
149
160
  def code_matches?(matcher)
150
161
  case matcher
151
162
  when Range
@@ -48,7 +48,11 @@ module HTTParty
48
48
  # NOTE: This will raise an argument error if the
49
49
  # charset does not exist
50
50
  encoding = Encoding.find(charset)
51
- text.force_encoding(encoding.to_s)
51
+ # Dummy encodings (UTF-7, UTF-32, ISO-2022-JP) raise on strip, regexes
52
+ # and parsing, so the body keeps the bytes it arrived with.
53
+ return text if encoding.dummy?
54
+
55
+ text.force_encoding(encoding)
52
56
  rescue ArgumentError
53
57
  text
54
58
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTParty
4
- VERSION = '0.24.4'
4
+ VERSION = '0.25.1'
5
5
  end
data/lib/httparty.rb CHANGED
@@ -28,7 +28,7 @@ module HTTParty
28
28
  end
29
29
 
30
30
  # == Common Request Options
31
- # Request methods (get, post, patch, put, delete, head, options) all take a common set of options. These are:
31
+ # Request methods (get, post, patch, put, delete, move, copy, head, options, mkcol, lock, unlock) all take a common set of options. These are:
32
32
  #
33
33
  # [:+body+:] Body of the request. If passed an object that responds to #to_hash, will try to normalize it first, by default passing it to ActiveSupport::to_params. Any other kind of object will get used as-is.
34
34
  # [:+http_proxyaddr+:] Address of proxy server to use.
@@ -80,7 +80,7 @@ module HTTParty
80
80
  #
81
81
  # class Foo
82
82
  # include HTTParty
83
- # logger Logger.new('http_logger'), :info, :apache
83
+ # logger ::Logger.new('http_logger'), :info, :apache
84
84
  # end
85
85
  def logger(logger, level = :info, format = :apache)
86
86
  default_options[:logger] = logger
@@ -104,7 +104,7 @@ module HTTParty
104
104
  #
105
105
  # class Foo
106
106
  # include HTTParty
107
- # http_proxy 'http://foo.com', 80, 'user', 'pass'
107
+ # http_proxy 'foo.com', 80, 'user', 'pass'
108
108
  # end
109
109
  def http_proxy(addr = nil, port = nil, user = nil, pass = nil)
110
110
  default_options[:http_proxyaddr] = addr
@@ -332,8 +332,9 @@ module HTTParty
332
332
  # even on redirects that should logically become GET requests.
333
333
  # A 303 redirect in HTTP signifies that the redirected url should normally
334
334
  # retrieved using a GET request, for instance, it is the output of a previous
335
- # POST. maintain_method_across_redirects respects this behavior, but you
336
- # can force HTTParty to resend_on_redirect even on 303 responses.
335
+ # POST. maintain_method_across_redirects respects this behavior (a HEAD
336
+ # request stays a HEAD), but you can force HTTParty to resend_on_redirect
337
+ # even on 303 responses.
337
338
  #
338
339
  # @example
339
340
  # class Foo
@@ -380,6 +381,8 @@ module HTTParty
380
381
  # Let's change it to this:
381
382
  # /?selected_ids=1&selected_ids=2&selected_ids=3
382
383
  #
384
+ # (For exactly this format, call disable_rails_query_string_format.)
385
+ #
383
386
  # Pass a Proc to the query normalizer which accepts the yielded query.
384
387
  #
385
388
  # @example Modifying Array query strings
@@ -387,9 +390,7 @@ module HTTParty
387
390
  # include HTTParty
388
391
  #
389
392
  # query_string_normalizer proc { |query|
390
- # query.map do |key, value|
391
- # value.map {|v| "#{key}=#{v}"}
392
- # end.join('&')
393
+ # URI.encode_www_form(query)
393
394
  # }
394
395
  # end
395
396
  #
@@ -686,6 +687,18 @@ module HTTParty
686
687
  Basement.options(*args, &block)
687
688
  end
688
689
 
690
+ def self.mkcol(*args, &block)
691
+ Basement.mkcol(*args, &block)
692
+ end
693
+
694
+ def self.lock(*args, &block)
695
+ Basement.lock(*args, &block)
696
+ end
697
+
698
+ def self.unlock(*args, &block)
699
+ Basement.unlock(*args, &block)
700
+ end
701
+
689
702
  def self.build_request(*args, &block)
690
703
  Basement.build_request(*args, &block)
691
704
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.4
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-11-20 00:00:00.000000000 Z
12
+ date: 2026-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: csv