Conversation
Updated Faraday to version 2.8 and added the faraday-typhoeus gem to enable HTTP/2 support and better mimic curl behavior, bypassing WAF/bot detection. Modified HttpClient to use the Typhoeus adapter. Updated Gemfile and Gemfile.lock dependencies accordingly.
A new step was added to update RubyGems before installing the PostgreSQL client in the build-and-test-not-master GitHub Actions workflow. This ensures the latest RubyGems system is used during CI runs.
Pinned the ffi gem to versions below 1.17.0 for compatibility with Ruby 2.7.7 and RubyGems 3.1.6. Updated the GitHub Actions workflow to enable bundler cache and removed the manual RubyGems update step.
Changed the 'User-Agent' header from Faraday v2.1.0 to v2.8.1 in multiple spec files to reflect the updated Faraday version. Also updated expected error in http_client_spec.rb from ConnectionFailed to TimeoutError for improved accuracy in test assertions.
…e-with-ctogov-api Add Faraday Typhoeus adapter for HTTP/2 support
There was a problem hiding this comment.
Pull Request Overview
This PR addresses CTGov API connection issues by switching from Faraday's default adapter to Typhoeus with HTTP/2 support, along with necessary dependency updates and test adjustments.
Key Changes:
- Updated Faraday to v2.7+ and added faraday-typhoeus gem for HTTP/2 support via libcurl
- Switched HTTP adapter from default to Typhoeus with HTTP/2 in the HttpClient service
- Updated all test stubs to reflect new Faraday v2.8.1 user agent string
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Gemfile | Pinned ffi gem for Ruby 2.7.7 compatibility, updated faraday to ~> 2.7, and added faraday-typhoeus dependency |
| app/services/http_client.rb | Replaced default Faraday adapter with Typhoeus configured for HTTP/2 |
| spec/services/http_client_spec.rb | Updated expected error type from ConnectionFailed to TimeoutError for retry behavior |
| spec/models/utils/util_updater_spec.rb | Updated stub headers to match Faraday v2.8.1 user agent |
| spec/models/clinical_trials_api_v2_spec.rb | Updated all WebMock stubs with new Faraday v2.8.1 user agent string |
| spec/mailers/notifier_spec.rb | Updated stub headers to match Faraday v2.8.1 user agent |
| README.md | Improved grammar, fixed download page URL from /snapshots to /downloads |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the HTTP client stack to improve compatibility, reliability, and HTTP/2 support, while also ensuring the codebase and tests reflect these changes. The most important changes include pinning gem versions for compatibility, switching the Faraday HTTP adapter to Typhoeus for better HTTP/2 support, and updating test expectations and stubs accordingly.
Dependency and HTTP client updates:
ffigem to< 1.17.0to maintain compatibility with Ruby 2.7.7 and RubyGems 3.1.6.faradayto version~> 2.7and added thefaraday-typhoeusgem to enable the Typhoeus adapter with HTTP/2 support.app/services/http_client.rbto use:typhoeuswith HTTP/2, replacing the default adapter.Test and spec updates:
Faraday v2.8.1) to match the updated gem version.spec/services/http_client_spec.rbto expect aFaraday::TimeoutErrorinstead ofFaraday::ConnectionFailedafter retries, reflecting changes in error handling with the new adapter.Documentation updates:
README.mdfor clarity, corrected links, and updated descriptions of the application and download page.