Skip to content

Replace nap with Net::HTTP - #785

Merged
amorde merged 2 commits into
CocoaPods:masterfrom
halogenandtoast:replace-nap-with-net-http
Nov 15, 2026
Merged

amorde merged 2 commits into
CocoaPods:masterfrom
halogenandtoast:replace-nap-with-net-http

Conversation

@halogenandtoast

@halogenandtoast halogenandtoast commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🌈

Replace nap with Net::HTTP

nap's README now asks projects to use Ruby's standard library instead of nap. This replaces it with Net::HTTP, using its default certificate verification against the system trust store. The CDN source already relies on that same store through Typhoeus.

What changed

  • New Pod::HTTP.perform(verb, url, headers = {}) makes a request with Net::HTTP and returns a Pod::HTTP::Response struct (status_code, headers, body, ok?, success?). headers keeps nap's shape: lowercase names mapping to arrays of values.
  • Pod::HTTP.validate_url, get_actual_url, Pod::GitHub and Pod::Metrics use it. CocoaPods' callers of validate_url (Validator#validate_url and #validate_screenshots) read success? and headers['content-type'].first, which both still work.
  • validate_url rescues URI::InvalidURIError plus Pod::HTTP::NETWORK_ERRORS, which covers the classes nap grouped under REST::Error. perform raises URI::InvalidURIError for URLs that are not HTTP, so validate_url returns nil for an ftp:// or mailto: homepage.
  • Proxies are looked up from the request URL (URI#find_proxy), so https_proxy and no_proxy apply. Net::HTTP's own :ENV lookup only reads http_proxy, even for https requests.
  • nap is removed from the gemspec and Gemfile.lock, along with the unused require 'rest' in cdn_source.rb.

Behaviour notes

Pod::HTTP.validate_url returns nil when a URL's certificate does not verify against the system trust store. pod lib lint and pod spec lint then report "There was a problem validating the URL" for that homepage, screenshot, social media or documentation URL. The Pod::GitHub helpers used by pod spec create raise OpenSSL::SSL::SSLError in the same situation. Users on networks that intercept TLS need their CA in the trust store their Ruby's OpenSSL uses, for example through SSL_CERT_FILE.

Once the related PRs are released, CocoaPods no longer installs nap, so a third-party plugin that calls REST without declaring nap as a dependency will need to add it. The CHANGELOG entry covers all of this.

Tests

New specs in spec/http_spec.rb:

  • a request to a local TLS server with a self-signed certificate raises OpenSSL::SSL::SSLError with certificate verify failed
  • an https_proxy environment setting is passed to Net::HTTP
  • validate_url returns nil when the request raises a network error
  • validate_url returns nil for ftp:// and mailto: URLs

The full suite and rubocop pass locally on Ruby 2.6 (macOS system Ruby, LibreSSL), 3.2 and 3.4 (1318 specifications, 0 failures).

Related

🤖 Generated with Claude Code

halogenandtoast and others added 2 commits November 1, 2026 19:28
nap's README now asks projects to use Ruby's standard library instead.
Add Pod::HTTP.perform, which makes requests with Net::HTTP using its
default certificate verification against the system trust store, and use
it for URL validation, the GitHub API and metrics. Proxy settings are
read from the request URL so https_proxy and no_proxy apply.

Pod::HTTP.validate_url now returns a Pod::HTTP::Response, which keeps
the status_code, headers, body, ok? and success? readers callers use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amorde
amorde merged commit fc6cb7e into CocoaPods:master Nov 15, 2026
6 checks passed
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.

2 participants