Skip to content

Stop loading resolv from net/http - #19316

Closed
hsbt wants to merge 1 commit into
ruby:masterfrom
hsbt:claude/magical-pare-153fd9
Closed

hsbt wants to merge 1 commit into
ruby:masterfrom
hsbt:claude/magical-pare-153fd9

Conversation

@hsbt

@hsbt hsbt commented Oct 13, 2026

Copy link
Copy Markdown
Member

require 'net/http' loads all of resolv, a DNS resolver of about 3,700 lines that also reads the system DNS configuration at load time. Net::HTTP#connect uses it only for Resolv::IPv4::Regex and Resolv::IPv6::Regex, to decide whether to send SNI.

I copied the regexps that the net-http vendored in RubyGems already inlines (ruby/rubygems@9f2bd5f66c), so the two copies stay identical. They accept the same strings as the resolv ones over 6 million generated inputs. A new test checks that net/http no longer defines Resolv.

Code that uses Resolv or SecureRandom after requiring only net/http now needs its own require. Nothing in this repository relies on that. A few gems on rubygems.org use Resolv that way, such as firespring_dev_commands.

Generated with Claude Code

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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

The following files are maintained in the following upstream repositories:

Please file a pull request to the above instead. Thank you!

@hsbt

hsbt commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

Superseded by 6095c59, which synced the same change from ruby/net-http#355.

@hsbt hsbt closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant