1078 Commits
Author SHA1 Message Date
Hiroshi SHIBATAandClaude Opus 5.5 6095c59c7e [ruby/net-http] Stop loading resolv from net/http
Net::HTTP required the whole DNS resolver, which also reads the system DNS configuration at load time, only to match Resolv::IPv4::Regex and Resolv::IPv6::Regex when deciding whether to send SNI. Use the same inlined regexps as the copy vendored in RubyGems, so that the two stay identical.

https://github.com/ruby/net-http/commit/5b42d75812

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 03:58:10 +00:00
Hiroshi SHIBATA 4001532694 [ruby/net-http] v0.10.0
https://github.com/ruby/net-http/commit/5d7c20a6cd
2026-10-08 03:18:01 +00:00
Sutou Kouhei b45655470c [ruby/net-http] Treat a whitespace-only header line as obs-fold
(https://github.com/ruby/net-http/pull/348)

The current implementation has a problem with the following case:

```ruby
print("HTTP/1.1 200 OK\r\n")
print("Content-Length: 5\r\n")
print(" \t\r\n")
print("X-After: value\r\n")
print("\r\n")
print("hello")
```

The `" \t\r\n"` line should be processed as obs-fold in RFC 9112:

https://www.rfc-editor.org/rfc/rfc9112.html#section-5.2

>     obs-fold     = OWS CRLF RWS
>                  ; obsolete line folding
>
>     A user agent that receives an obs-fold in a response message that
>     is not within a "message/http" container MUST replace each received
>     obs-fold with one or more SP octets prior to interpreting the field
>     value.

But it's processed as the header part end:

Header:

```text
HTTP/1.1 200 OK
Content-Length: 5
```

Body:

```text
X-After: value

hello
```

It must be processed as the following (whitespace only obs-fold is
ignored):

Header:

```text
HTTP/1.1 200 OK
Content-Length: 5
X-After: value
```

Body:

```text
hello
```

https://github.com/ruby/net-http/commit/6e2bc82919
2026-10-06 23:37:25 +00:00
Hiroshi SHIBATA 028dcaa3c9 [ruby/net-protocol] v0.4.0
https://github.com/ruby/net-protocol/commit/c1f66145f7
2026-09-17 03:30:00 +00:00
Oskar Eichler 550591bb5a [ruby/net-protocol] Restore message logging and clear write state on exceptional exits
https://github.com/ruby/net-protocol/commit/a1bd220aad
2026-09-17 03:25:27 +00:00
Oskar Eichler d9c88e8428 [ruby/net-protocol] Wait for readability when an SSL write requests it
https://github.com/ruby/net-protocol/commit/85361b97cd
2026-09-17 03:25:27 +00:00
Oskar Eichler 48c7a6ae3d [ruby/net-protocol] Reject negative read lengths before changing the buffer
https://github.com/ruby/net-protocol/commit/44b2dcb2f4
2026-09-17 03:25:27 +00:00
Charles Oliver Nutter 16fd986706 [ruby/net-protocol] Only require io/wait on Ruby versions earlier than 3.2
The io-wait library transitioned to core in 3.2 and is now an empty
and deprecated gem. Only require it if running on Ruby versions
earlier than 3.2.

https://github.com/ruby/net-protocol/commit/1f84c9c60b
2026-09-15 14:18:53 +00:00
Hiroshi SHIBATAandClaude Opus 5 4eb03b31cb [ruby/net-http] Let Transfer-Encoding override Content-Length
Once chunked is not the final transfer coding, read_body_0 fell through
to Content-Length and framed the body by it, which leaves the client and
the server disagreeing about where the response ends.

See RFC 9112 Section 6.3:
https://www.rfc-editor.org/rfc/rfc9112.html#section-6.3

    If a message is received with both a Transfer-Encoding and a
    Content-Length header field, the Transfer-Encoding overrides the
    Content-Length.

https://github.com/ruby/net-http/commit/9fb5b93b52

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 02:55:16 +00:00
Hiroshi SHIBATAandClaude Opus 5 21bc49cf73 [ruby/net-http] Require chunked to be the final transfer coding
Net::HTTPHeader#chunked? matched the token anywhere in
Transfer-Encoding, so a response carrying `chunked, gzip` was
chunk-framed and the bytes after the terminating chunk were left
unread on the connection.

See RFC 9112 Section 6.3:
https://www.rfc-editor.org/rfc/rfc9112.html#section-6.3

    If a Transfer-Encoding header field is present in a response and
    the chunked transfer coding is not the final encoding, the message
    body length is determined by reading the connection until it is
    closed by the server.

https://github.com/ruby/net-http/commit/e70762aaf9

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 02:55:16 +00:00
Sutou Kouhei 2c260b8dec [ruby/net-http] Make Content-Length handling strict
(https://github.com/ruby/net-http/pull/324)

`Content-Length` value must have only digits.

See also RFC 9110 Section 8.6:
https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6

    Content-Length = 1*DIGIT

The current implementation accepts garbage before/after digits such as
`abc5` and `5abc`.

This rejects these invalid values.

But this accepts same values in one `Content-Length`

    Content-Length: 5, 5

and in multiple `Content-Length`es:

    Content-Length: 5
    Content-Length: 5

This is for the following part in the RFC:

https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6-13

> Likewise, a sender MUST NOT forward a message with a Content-Length
> header field value that does not match the ABNF above, with one
> exception: a recipient of a Content-Length header field value
> consisting of the same decimal value repeated as a comma-separated
> list (e.g, "Content-Length: 42, 42") MAY either reject the message
> as invalid or replace that invalid field value with a single
> instance of the decimal value, since this likely indicates that a
> duplicate was generated or combined by an upstream message
> processor.

https://github.com/ruby/net-http/commit/23e859e92e
2026-08-26 00:46:26 +00:00
Hiroshi SHIBATAandClaude Opus 5 05e1f1f648 [ruby/net-http] Limit the number of informational responses per request
A peer that keeps sending 1xx responses keeps the client in the read
loop of transport_request indefinitely, since the per-response header
limit resets for each response. Cap the count at 100, the same value
CPython's http.client uses.

https://github.com/ruby/net-http/commit/39cf5f648a

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 00:33:27 +00:00
Hiroshi SHIBATAandClaude Fable 5 331568b2a9 [ruby/net-http] Limit read length of a single response line
The response header cap added by #219 applies only once a complete line
has arrived, so a server that never sends a line terminator can still
grow the read buffer without bound, as reported in #315. Read the
status line, header lines, chunk-size lines and chunk trailers through
net-protocol's readuntil(limit:) so they fail with
Net::HTTPBadResponse at MAX_RESPONSE_HEADER_LENGTH, and require the
net-protocol that provides it.

The cumulative header budget stays separate from the per-line limit so
that exhausting the total still reports 'response header too large'
rather than blaming a line that is not long.

https://github.com/ruby/net-http/issues/315

https://github.com/ruby/net-http/commit/132c8cc1b1

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 23:13:17 +00:00
Hiroshi SHIBATA 7f00b21798 [ruby/net-protocol] v0.3.0
https://github.com/ruby/net-protocol/commit/fb347d5ff4
2026-08-25 22:49:41 +00:00
Hiroshi SHIBATAandClaude Fable 5 c344021a11 [ruby/net-protocol] Trim the comments added with the readuntil rewind
The floor's two reasons fit in one block, and the two tests that
restated them are named for what they cover.

https://github.com/ruby/net-protocol/commit/6ffd258b7c

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 11:19:05 +00:00
Hiroshi SHIBATAandClaude Fable 5 ee3b80cdb4 [ruby/net-protocol] Add limit option to Net::BufferedIO#readuntil
readuntil buffers until the terminator arrives, so a peer that never
sends one grows the read buffer without bound. The limit lets a protocol
implementation cap what a single read may return, raising the new
Net::ReadLimitExceeded instead of reading on.

The exception derives from ProtocolError because an over-long line is
the peer violating the protocol rather than an I/O failure, and because
IOError would place it in the generic socket-error rescue that Net::HTTP
retries on.

https://github.com/ruby/net-http/issues/315

https://github.com/ruby/net-protocol/commit/e1b38d98b7

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 11:19:05 +00:00
Hiroshi SHIBATAandClaude Fable 5 e7619442d2 [ruby/net-protocol] Fix readuntil missing a terminator that spans two reads
BufferedIO#readuntil resumed searching at the previous buffer end, so a
multi-byte terminator split across two fills, such as "\r" ending one
chunk and "\n" starting the next, was never matched and readuntil
returned data past the terminator. Rewind the search by
terminator.bytesize - 1 before refilling, floored at @rbuf_offset.

https://github.com/ruby/net-protocol/commit/84ef3aba09

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 09:40:43 +00:00
Sean Doyle 59d4afaade [ruby/net-http] Add support for HTTP QUERY method
Closes https://github.com/ruby/net-http/issues/202

As of June 2026, [RFC 10008][] is a proposed standard.

From the RFC Abstract:

> This specification defines the QUERY method for HTTP. A QUERY requests
> that the request target process the enclosed content in a safe and
> idempotent manner and then respond with the result of that processing.
> This is similar to POST requests, but QUERY requests can be
> automatically repeated or restarted without concern for partial state
> changes.

This commit proposes support for the HTTP Query method by way of the
`Net::HTTP::Query` class along with the corresponding `#query` and
`#request_query` methods.

[RFC 10008]: https://www.rfc-editor.org/rfc/rfc10008.html

https://github.com/ruby/net-http/commit/76b11b3a26
2026-07-10 03:29:36 +00:00
Nobuyoshi Nakada 9404598418 [DOC] Fix rdoc-ref replacement
Replace attributes and decode escaped punctuations.

```
Net/HTTP.html: `rdoc-ref:OpenSSL::SSL::SSLContext#max_version-3D` can't be resolved for ``
Net/HTTP.html: `rdoc-ref:OpenSSL::SSL::SSLContext#min_version-3D` can't be resolved for ``
Net/HTTP.html: `rdoc-ref:OpenSSL::SSL::SSLContext#ssl_version-3D` can't be resolved for ``
Net/HTTP.html: `rdoc-ref:OpenSSL::SSL::SSLContext#attribute-i-verify_hostname` can't be resolved for ``
```
2026-06-24 23:18:05 +09:00
Hiroshi SHIBATAandClaude Opus 4.8 3b6c8999f8 [ruby/net-http] Fix broken ENV link in proxy_from_env= doc
RDoc parsed ENV['http_proxy'] inside the link label as a cross-reference,
emitting a stray <a href="'http_proxy'">ENV</a> and breaking the
surrounding {label}[url] markup. Drop the subscript from the label.

https://github.com/ruby/net-http/issues/292

https://github.com/ruby/net-http/commit/0c2105cde6

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 04:44:14 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 02741998f4 [ruby/net-http] Fix broken OpenSSL::SSL::SSLContext doc links
The {label}[url] markup pointed at OpenSSL::SSL::SSL::Context#..., which
RDoc emitted verbatim as a relative href and never resolved. Point them
at the full SSLContext documentation URLs instead.

https://github.com/ruby/net-http/issues/288
https://github.com/ruby/net-http/issues/289
https://github.com/ruby/net-http/issues/290
https://github.com/ruby/net-http/issues/291
https://github.com/ruby/net-http/issues/293
https://github.com/ruby/net-http/issues/294

https://github.com/ruby/net-http/commit/d6f04e7e70

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 04:44:14 +00:00
5900b2f53d [ruby/net-http] Limit the total size of response headers
each_response_header read header lines until the blank separator with no
bound on their total size, so a server could exhaust client memory by
sending a large header block. Cap the cumulative size at 1 MiB and raise
Net::HTTPBadResponse once it is exceeded.

https://github.com/ruby/net-http/commit/ebe8f3876f

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 16:02:15 +09:00
6f3e462182 [ruby/net-http] Validate header key and field value length in set_field
The length limits only ran in initialize_http_header, which responses
bypass: each_response_header builds the response through add_field and
set_field, so an oversized response header field was never bounded. Check
the field value length in set_field and append_field_value, and fold the
key length check into validate_field_name so set_field and
initialize_http_header share one place for validating field names.

https://github.com/ruby/net-http/commit/ab084fdc0c

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 16:02:15 +09:00
Hiroshi SHIBATAandClaude Fable 5 fce7fb63fc [ruby/net-http] Reject CR/LF in multipart boundary
A custom boundary is interpolated into the part separators as-is, so a
boundary containing CR/LF could forge part headers in the same way as
the field name and filename.

https://github.com/ruby/net-http/commit/44c480b336

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 01:50:53 +00:00
Hiroshi SHIBATAandClaude Fable 5 bb4b4f1fdf [ruby/net-http] Coerce multipart content type to a string before validating
The CR/LF check via Regexp#match? requires a String, but the per-part
content type was previously interpolated through to_s and accepted any
object such as a Symbol. Coerce it first to keep that behavior.

https://github.com/ruby/net-http/commit/c07d6581ce

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 01:50:53 +00:00
Hiroshi SHIBATAandClaude Fable 5 94c133a368 [ruby/net-http] Reject CR/LF in multipart field name, filename, and content type
encode_multipart_form_data interpolated the field name, filename, and
per-part content type into Content-Disposition and Content-Type lines
with only quote_string escaping backslash and double quote, so CR/LF in
any of them could forge part headers and tamper with the request.

Fixes https://github.com/ruby/net-http/issues/195

https://github.com/ruby/net-http/commit/02a962fce2

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 01:50:53 +00:00
Hiroshi SHIBATAandClaude Fable 5 cb8a34d785 [ruby/net-http] Validate Content-Type value set by set_content_type
set_content_type assigned to @header directly, bypassing the CR/LF
validation in set_field, so a crafted media type or parameter could
inject header lines.

https://github.com/ruby/net-http/commit/5fe0f96190

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 01:50:53 +00:00
Hiroshi SHIBATAandClaude Fable 5 ebddeca11d [ruby/net-http] Reject control characters and colon in header field names
Field values and the request line are already validated against CR/LF,
but field names were interpolated into the request as-is, allowing
header injection via the key. Validate names in set_field and
initialize_http_header, which cover all paths into @header with a
user-supplied key.

https://github.com/ruby/net-http/commit/4f13ea5047

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 01:50:53 +00:00
Erik Berlin 2602e3a9b6 [ruby/net-http] Add existing RBS interface tests from ruby/rbs repo
https://github.com/ruby/net-http/commit/2842ca5539
2026-03-17 08:52:13 +00:00
BurdetteLamar 474dd92583 [ruby/net-http] [DOC] Fix links in module Net
https://github.com/ruby/net-http/commit/e95d812325
2026-02-06 23:34:57 +00:00
BurdetteLamar 40e3e43b93 [ruby/net-http] [DOC] Fix links in requests.rb
https://github.com/ruby/net-http/commit/a232aea2fc
2026-01-29 05:02:36 +00:00
Peter Zhu 969fd30cb1 [ruby/net-http] [DOC] Fix links
The RDoc link format has changed so these are all broken links.

https://github.com/ruby/net-http/commit/97fe6085c3
2026-01-27 03:40:07 +00:00
Benoit Daloze fda7019c80 [ruby/net-protocol] Add Net::Protocol::TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
* To find out efficiently if TCPSocket#initialize supports the open_timeout keyword argument.

https://github.com/ruby/net-protocol/commit/738c06f950
2025-12-26 11:00:51 +09:00
Hiroshi SHIBATA 26447b3597 [ruby/net-http] v0.9.1
https://github.com/ruby/net-http/commit/8cee86e939
2025-12-17 15:47:43 +09:00
Kazuki Yamaguchi b80fc8bd84 [ruby/net-http] Freeze more constants for Ractor compatibility
Freeze Net::HTTP::SSL_ATTRIBUTES and IDEMPOTENT_METHODS_. Both constants
have been marked as :nodoc:.

Together with https://github.com/ruby/openssl/issues/521, this enables
HTTPS clients in non-main Ractors on Ruby 4.0.

https://github.com/ruby/net-http/commit/f24b3b358b
2025-12-17 15:47:43 +09:00
Hiroshi SHIBATA fedafec78b [ruby/net-http] v0.9.0
https://github.com/ruby/net-http/commit/3ccf0c8e6a
2025-12-17 15:47:43 +09:00
Misaki Shioi 7b5691c3b0 Socket.tcp and TCPSocket.new raises IO::TiemoutError with user specified timeout (#15602)
* `Socket.tcp` and `TCPSocket.new` raises `IO::TiemoutError` with user specified timeout

In https://github.com/ruby/ruby/pull/11880, `rsock_connect()` was changed to raise `IO::TimeoutError` when a user-specified timeout occurs.
However, when `TCPSocket.new` attempts to connect to multiple destinations, it does not use `rsock_connect()`, and instead raises `Errno::ETIMEDOUT` on timeout.
As a result, the exception class raised on timeout could differ depending on whether there were multiple destinations or not.

To align this behavior with the implementation of `rsock_connect()`, this change makes `TCPSocket.new` raise `IO::TimeoutError` when a user-specified timeout occurs.
Similarly, `Socket.tcp` is updated to raise `IO::TimeoutError` when a timeout occurs within the method.
(Note that the existing behavior of `Addrinfo#connect_internal`, which Socket.tcp depends on internally and which raises `Errno::ETIMEDOUT` on timeout, is not changed.)

* [ruby/net-http] Raise `Net::OpenTimeout` when `TCPSocket.open` raises `IO::TimeoutError`.

With the changes in https://github.com/ruby/ruby/pull/15602, `TCPSocket.open` now raises `IO::TimeoutError` when a user-specified timeout occurs.
This change updates #connect to handle this case accordingly.

https://github.com/ruby/net-http/commit/f64109e1cf
2025-12-17 15:02:26 +09:00
Benoit Daloze 99133a66f3 [ruby/net-http] Check whether TCPSocket#initialize supports open_timeout once and without exceptions
* See discussion in https://github.com/ruby/net-http/pull/224
* This check is known to work on at least CRuby, TruffleRuby and JRuby.
* Exceptions show up with `ruby -d`/`$DEBUG == true` and would show for every Net::HTTP instance.

https://github.com/ruby/net-http/commit/8c76f92779
2025-12-09 10:37:15 +00:00
Hiroshi SHIBATA 79c57d747f Fixed by misspell -w -error -source=text 2025-12-09 17:48:57 +09:00
Daisuke Aritomo ea415e9636 [ruby/net-http] open: Never call Timeout.timeout in rescue clause
The try-open_timeout-then-fallback-to-timeout introduced in
https://github.com/ruby/net-http/commit/1903cedd8cd0 works well, but when it errors
due to any reason in Rubies which do not support `open_timeout`, it
spits the rescued ArgumentError that is unrelated to user code and not
actionable.

    Net::HTTP.start('foo.bar', 80)

    /.../net-http-0.8.0/lib/net/http.rb:1691:in 'TCPSocket#initialize': Failed to open TCP connection to foo.bar:80 (getaddrinfo(3): nodename nor servname provided, or not known) (Socket::ResolutionError)
            from /.../net-http-0.8.0/lib/net/http.rb:1691:in 'IO.open'
            from /.../net-http-0.8.0/lib/net/http.rb:1691:in 'block in Net::HTTP#connect'
            from /.../timeout-0.4.4/lib/timeout.rb:188:in 'block in Timeout.timeout'
            from /.../timeout-0.4.4/lib/timeout.rb:195:in 'Timeout.timeout'
            from /.../net-http-0.8.0/lib/net/http.rb:1690:in 'Net::HTTP#connect'
            from /.../net-http-0.8.0/lib/net/http.rb:1655:in 'Net::HTTP#do_start'
            from /.../net-http-0.8.0/lib/net/http.rb:1635:in 'Net::HTTP#start'
            from /.../net-http-0.8.0/lib/net/http.rb:1064:in 'Net::HTTP.start'
            (snip)
    /.../net-http-0.8.0/lib/net/http.rb:1682:in 'TCPSocket#initialize': unknown keyword: :open_timeout (ArgumentError)

              sock = TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            from /.../net-http-0.8.0/lib/net/http.rb:1682:in 'IO.open'
            from /.../net-http-0.8.0/lib/net/http.rb:1682:in 'Net::HTTP#connect'
            from /.../net-http-0.8.0/lib/net/http.rb:1655:in 'Net::HTTP#do_start'
            from /.../net-http-0.8.0/lib/net/http.rb:1635:in 'Net::HTTP#start'
            from /.../net-http-0.8.0/lib/net/http.rb:1064:in 'Net::HTTP.start'
            (snip)
            ... 8 levels...

This patch suppresses the ArgumentError by moving the retry out of the
rescue clause.

https://github.com/ruby/net-http/commit/86232d62f5
2025-12-05 12:34:14 +00:00
Sorah Fukumori 244a4bedc2 [ruby/net-http] releng v0.8.0
https://github.com/ruby/net-http/commit/9d65391f54
2025-11-13 16:01:15 +00:00
Taketo Takashima 1d903b727f [ruby/net-http] Drop support for Ruby 2.6
https://github.com/ruby/net-http/commit/a3a5bc45f6
2025-11-13 14:33:22 +00:00
2ab21f56f9 [ruby/net-http] Fix handling of IPv6 literal hosts in Net::HTTPGenericRequest
Update uri dependency to version 0.11.0 or later to use `URI::HTTP#authority` and `URI#parse` without scheme

https://github.com/ruby/net-http/commit/3d4f06bd7f

Co-authored-by: 0x1eef <0x1eef@users.noreply.github.com>
Co-authored-by: Sorah Fukumori <sora134@gmail.com>
2025-11-13 14:33:22 +00:00
Yasuo Honda c6997ddf3e [ruby/net-http] Replace Ruby 3.5 with Ruby 4.0
This commit updates the Ruby version to follow the commit in Ruby master branch.
https://github.com/ruby/ruby/commit/6d81969b475262aba251e99b518181bdf7c5a523

https://github.com/ruby/net-http/commit/1e48cfaaf7
2025-11-12 01:09:49 +00:00
Nobuyoshi Nakada 3147df87ba [ruby/net-http] [DOC] Suppress documentation for internals
https://github.com/ruby/net-http/commit/b7c586985a
2025-11-10 03:38:04 +00:00
Daisuke Aritomo f29d772a73 [ruby/net-http] Remember if TCPSocket impl supports open_timeout
For open_timeout support detection, the previous implementation relied
on an ArgumentError being raised and then rescued. In Ruby, rescue is a
rather expensive operation and should be avoided when possible.

This patch reduces the number of begin-rescues by remembering if the
TCPSocket implementation supports open_timeout.

https://github.com/ruby/net-http/commit/06d982f3a1
2025-11-10 02:40:46 +00:00
Daisuke Aritomo 97efbc47d0 [ruby/net-http] Ruby 2 compat
https://github.com/ruby/net-http/commit/09bf573dd5
2025-11-10 02:40:46 +00:00
Daisuke Aritomo f710e6bb54 [ruby/net-http] Replace Timeout.timeout with TCPSocket.open(open_timeout:) when available
This patch replaces the implementation of #open_timeout from Timeout.timeout from the builtin timeout in TCPSocket.open, which was introduced in Ruby 3.5 (https://bugs.ruby-lang.org/issues/21347).

The builtin timeout in TCPSocket.open is better in several ways than Timeout.timeout. It does not rely on a separate Ruby Thread for monitoring Timeout (which is what the timeout library internally does).

Furthermore, it is compatible with Ractors, as opposed to Timeout.timeout (it internally uses Thread::Mutex which can not be used in non-main Ractors).
This change allows the following code to work.

    require 'net/http'
    Ractor.new {
      uri = URI('http://example.com/')
      http = Net::HTTP.new(uri.host, uri.port)
      http.open_timeout = 1
      http.get(uri.path)
    }.value

In Ruby <3.5 environments where `TCPSocket.open` does not have the `open_timeout` option, I have kept the behavior unchanged. net/http will use `Timeout.timeout { TCPSocket.open }`.

https://github.com/ruby/net-http/commit/728eb8fc42
2025-11-10 02:40:46 +00:00
Nobuyoshi Nakada 4fe0342a86 Reapply "[ruby/net-http] [DOC] Suppress documentation for internals"
This reverts commit af610e107c.
Reverted by a mistake.
2025-11-09 22:18:37 +09:00
Nobuyoshi Nakada af610e107c Revert "[ruby/net-http] [DOC] Suppress documentation for internals"
This reverts commit 155cdce539.
2025-11-09 22:11:40 +09:00