net-http 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91e4788b01779aad8b10d32588d21f857d66a5b9d752bd4226b8b624b651877d
4
- data.tar.gz: 222d82ca817154eef246ad62f68c571deb2bfb6bc5bcfceca185066ac7773ff0
3
+ metadata.gz: 131d16d2933696673a49f39953264a4b9cdf3385bcd4da1a3ec3a62abcdeeb53
4
+ data.tar.gz: 778f8e1b25b8f4cc1e96cfb9850a39663f35d82586eededc930372134df5a728
5
5
  SHA512:
6
- metadata.gz: 5f1d6bbc6f5cea9b1b27c93dc5b2aba277e3fa6919aecc3044b69e5dd1a628b2e6a2ccc4074c3b6d3ec2bc98b59a47ce6fa6b7e340cbb7a892633804347885ff
7
- data.tar.gz: 45aacf67fd2756870eb98199970d0bcd584547a5731e457fcce93304c93cdbe77c9c2a3a633395215e39dee657b912f542b459cccab4a05fe913af2819878952
6
+ metadata.gz: c14a580bfe0a9bdbd509a9a016edfe3fbf272f408aeb6f14203def14934f6f68392d874e5c2fd4b035013e2ccf3e0fa8e7380a001c5b39c244bfefa29d23a2f3
7
+ data.tar.gz: f104edcc06607f63009e55cbf345e897ab6c9a76e083642d5ad189898e82b304948137a062af28238d2cc187853d151581af960ce408c749fff77f23a6377b3f
@@ -102,6 +102,31 @@ class Net::HTTPGenericRequest
102
102
  "\#<#{self.class} #{@method}>"
103
103
  end
104
104
 
105
+ # Returns a string representation of the request with the details for pp:
106
+ #
107
+ # require 'pp'
108
+ # post = Net::HTTP::Post.new(uri)
109
+ # post.inspect # => "#<Net::HTTP::Post POST>"
110
+ # post.pretty_inspect
111
+ # # => #<Net::HTTP::Post
112
+ # POST
113
+ # path="/"
114
+ # headers={"accept-encoding" => ["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
115
+ # "accept" => ["*/*"],
116
+ # "user-agent" => ["Ruby"],
117
+ # "host" => ["www.ruby-lang.org"]}>
118
+ #
119
+ def pretty_print(q)
120
+ q.object_group(self) {
121
+ q.breakable
122
+ q.text @method
123
+ q.breakable
124
+ q.text "path="; q.pp @path
125
+ q.breakable
126
+ q.text "headers="; q.pp to_hash
127
+ }
128
+ end
129
+
105
130
  ##
106
131
  # Don't automatically decode response content-encoding if the user indicates
107
132
  # they want to handle it.
@@ -260,7 +285,6 @@ class Net::HTTPGenericRequest
260
285
  def send_request_with_body(sock, ver, path, body)
261
286
  self.content_length = body.bytesize
262
287
  delete 'Transfer-Encoding'
263
- supply_default_content_type
264
288
  write_header sock, ver, path
265
289
  wait_for_continue sock, ver if sock.continue_timeout
266
290
  sock.write body
@@ -271,7 +295,6 @@ class Net::HTTPGenericRequest
271
295
  raise ArgumentError,
272
296
  "Content-Length not given and Transfer-Encoding is not `chunked'"
273
297
  end
274
- supply_default_content_type
275
298
  write_header sock, ver, path
276
299
  wait_for_continue sock, ver if sock.continue_timeout
277
300
  if chunked?
@@ -373,12 +396,6 @@ class Net::HTTPGenericRequest
373
396
  buf.clear
374
397
  end
375
398
 
376
- def supply_default_content_type
377
- return if content_type()
378
- warn 'net/http: Content-Type did not set; using application/x-www-form-urlencoded', uplevel: 1 if $VERBOSE
379
- set_content_type 'application/x-www-form-urlencoded'
380
- end
381
-
382
399
  ##
383
400
  # Waits up to the continue timeout for a response from the server provided
384
401
  # we're speaking HTTP 1.1 and are expecting a 100-continue response.
@@ -411,4 +428,3 @@ class Net::HTTPGenericRequest
411
428
  end
412
429
 
413
430
  end
414
-
@@ -1104,7 +1104,7 @@ class Net::HTTPResponse
1104
1104
  '3' => Net::HTTPRedirection,
1105
1105
  '4' => Net::HTTPClientError,
1106
1106
  '5' => Net::HTTPServerError
1107
- }
1107
+ }.freeze
1108
1108
  CODE_TO_OBJ = {
1109
1109
  '100' => Net::HTTPContinue,
1110
1110
  '101' => Net::HTTPSwitchProtocol,
@@ -1170,5 +1170,5 @@ class Net::HTTPResponse
1170
1170
  '508' => Net::HTTPLoopDetected,
1171
1171
  '510' => Net::HTTPNotExtended,
1172
1172
  '511' => Net::HTTPNetworkAuthenticationRequired,
1173
- }
1173
+ }.freeze
1174
1174
  end
data/lib/net/http.rb CHANGED
@@ -475,8 +475,7 @@ module Net #:nodoc:
475
475
  #
476
476
  # - {::start}[rdoc-ref:Net::HTTP.start]:
477
477
  # Begins a new session in a new \Net::HTTP object.
478
- # - {#started?}[rdoc-ref:Net::HTTP#started?]
479
- # (aliased as {#active?}[rdoc-ref:Net::HTTP#active?]):
478
+ # - {#started?}[rdoc-ref:Net::HTTP#started?]:
480
479
  # Returns whether in a session.
481
480
  # - {#finish}[rdoc-ref:Net::HTTP#finish]:
482
481
  # Ends an active session.
@@ -556,18 +555,15 @@ module Net #:nodoc:
556
555
  # Sends a PUT request and returns a response object.
557
556
  # - {#request}[rdoc-ref:Net::HTTP#request]:
558
557
  # Sends a request and returns a response object.
559
- # - {#request_get}[rdoc-ref:Net::HTTP#request_get]
560
- # (aliased as {#get2}[rdoc-ref:Net::HTTP#get2]):
558
+ # - {#request_get}[rdoc-ref:Net::HTTP#request_get]:
561
559
  # Sends a GET request and forms a response object;
562
560
  # if a block given, calls the block with the object,
563
561
  # otherwise returns the object.
564
- # - {#request_head}[rdoc-ref:Net::HTTP#request_head]
565
- # (aliased as {#head2}[rdoc-ref:Net::HTTP#head2]):
562
+ # - {#request_head}[rdoc-ref:Net::HTTP#request_head]:
566
563
  # Sends a HEAD request and forms a response object;
567
564
  # if a block given, calls the block with the object,
568
565
  # otherwise returns the object.
569
- # - {#request_post}[rdoc-ref:Net::HTTP#request_post]
570
- # (aliased as {#post2}[rdoc-ref:Net::HTTP#post2]):
566
+ # - {#request_post}[rdoc-ref:Net::HTTP#request_post]:
571
567
  # Sends a POST request and forms a response object;
572
568
  # if a block given, calls the block with the object,
573
569
  # otherwise returns the object.
@@ -605,8 +601,7 @@ module Net #:nodoc:
605
601
  # Returns whether +self+ is a proxy class.
606
602
  # - {#proxy?}[rdoc-ref:Net::HTTP#proxy?]:
607
603
  # Returns whether +self+ has a proxy.
608
- # - {#proxy_address}[rdoc-ref:Net::HTTP#proxy_address]
609
- # (aliased as {#proxyaddr}[rdoc-ref:Net::HTTP#proxyaddr]):
604
+ # - {#proxy_address}[rdoc-ref:Net::HTTP#proxy_address]:
610
605
  # Returns the proxy address.
611
606
  # - {#proxy_from_env?}[rdoc-ref:Net::HTTP#proxy_from_env?]:
612
607
  # Returns whether the proxy is taken from an environment variable.
@@ -718,8 +713,7 @@ module Net #:nodoc:
718
713
  # === \HTTP Version
719
714
  #
720
715
  # - {::version_1_2?}[rdoc-ref:Net::HTTP.version_1_2?]
721
- # (aliased as {::is_version_1_2?}[rdoc-ref:Net::HTTP.is_version_1_2?]
722
- # and {::version_1_2}[rdoc-ref:Net::HTTP.version_1_2]):
716
+ # (aliased as {::version_1_2}[rdoc-ref:Net::HTTP.version_1_2]):
723
717
  # Returns true; retained for compatibility.
724
718
  #
725
719
  # === Debugging
@@ -730,7 +724,7 @@ module Net #:nodoc:
730
724
  class HTTP < Protocol
731
725
 
732
726
  # :stopdoc:
733
- VERSION = "0.6.0"
727
+ VERSION = "0.7.0"
734
728
  HTTPVersion = '1.1'
735
729
  begin
736
730
  require 'zlib'
@@ -1535,7 +1529,7 @@ module Net #:nodoc:
1535
1529
  :verify_hostname,
1536
1530
  ] # :nodoc:
1537
1531
 
1538
- SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym } # :nodoc:
1532
+ SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym }.freeze # :nodoc:
1539
1533
 
1540
1534
  # Sets or returns the path to a CA certification file in PEM format.
1541
1535
  attr_accessor :ca_file
@@ -1552,11 +1546,11 @@ module Net #:nodoc:
1552
1546
  attr_accessor :cert_store
1553
1547
 
1554
1548
  # Sets or returns the available SSL ciphers.
1555
- # See {OpenSSL::SSL::SSLContext#ciphers=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ciphers-3D].
1549
+ # See {OpenSSL::SSL::SSLContext#ciphers=}[OpenSSL::SSL::SSL::Context#ciphers=].
1556
1550
  attr_accessor :ciphers
1557
1551
 
1558
1552
  # Sets or returns the extra X509 certificates to be added to the certificate chain.
1559
- # See {OpenSSL::SSL::SSLContext#add_certificate}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-add_certificate].
1553
+ # See {OpenSSL::SSL::SSLContext#add_certificate}[OpenSSL::SSL::SSL::Context#add_certificate].
1560
1554
  attr_accessor :extra_chain_cert
1561
1555
 
1562
1556
  # Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
@@ -1566,15 +1560,15 @@ module Net #:nodoc:
1566
1560
  attr_accessor :ssl_timeout
1567
1561
 
1568
1562
  # Sets or returns the SSL version.
1569
- # See {OpenSSL::SSL::SSLContext#ssl_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ssl_version-3D].
1563
+ # See {OpenSSL::SSL::SSLContext#ssl_version=}[OpenSSL::SSL::SSL::Context#ssl_version=].
1570
1564
  attr_accessor :ssl_version
1571
1565
 
1572
1566
  # Sets or returns the minimum SSL version.
1573
- # See {OpenSSL::SSL::SSLContext#min_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-min_version-3D].
1567
+ # See {OpenSSL::SSL::SSLContext#min_version=}[OpenSSL::SSL::SSL::Context#min_version=].
1574
1568
  attr_accessor :min_version
1575
1569
 
1576
1570
  # Sets or returns the maximum SSL version.
1577
- # See {OpenSSL::SSL::SSLContext#max_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-max_version-3D].
1571
+ # See {OpenSSL::SSL::SSLContext#max_version=}[OpenSSL::SSL::SSL::Context#max_version=].
1578
1572
  attr_accessor :max_version
1579
1573
 
1580
1574
  # Sets or returns the callback for the server certification verification.
@@ -1590,7 +1584,7 @@ module Net #:nodoc:
1590
1584
 
1591
1585
  # Sets or returns whether to verify that the server certificate is valid
1592
1586
  # for the hostname.
1593
- # See {OpenSSL::SSL::SSLContext#verify_hostname=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#attribute-i-verify_mode].
1587
+ # See {OpenSSL::SSL::SSLContext#verify_hostname=}[OpenSSL::SSL::SSL::Context#verify_hostname=].
1594
1588
  attr_accessor :verify_hostname
1595
1589
 
1596
1590
  # Returns the X509 certificate chain (an array of strings)
@@ -1923,7 +1917,8 @@ module Net #:nodoc:
1923
1917
  private
1924
1918
 
1925
1919
  def unescape(value)
1926
- require 'cgi/util'
1920
+ require 'cgi/escape'
1921
+ require 'cgi/util' unless defined?(CGI::EscapeExt)
1927
1922
  CGI.unescape(value)
1928
1923
  end
1929
1924
 
data/net-http.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
25
25
  spec.licenses = ["Ruby", "BSD-2-Clause"]
26
26
 
27
+ spec.metadata["changelog_uri"] = spec.homepage + "/releases"
27
28
  spec.metadata["homepage_uri"] = spec.homepage
28
29
  spec.metadata["source_code_uri"] = spec.homepage
29
30
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NARUSE, Yui
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: uri
@@ -57,9 +56,9 @@ licenses:
57
56
  - Ruby
58
57
  - BSD-2-Clause
59
58
  metadata:
59
+ changelog_uri: https://github.com/ruby/net-http/releases
60
60
  homepage_uri: https://github.com/ruby/net-http
61
61
  source_code_uri: https://github.com/ruby/net-http
62
- post_install_message:
63
62
  rdoc_options: []
64
63
  require_paths:
65
64
  - lib
@@ -74,8 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
73
  - !ruby/object:Gem::Version
75
74
  version: '0'
76
75
  requirements: []
77
- rubygems_version: 3.5.11
78
- signing_key:
76
+ rubygems_version: 3.6.9
79
77
  specification_version: 4
80
78
  summary: HTTP client api for Ruby.
81
79
  test_files: []