Closed fengmk2 closed 3 months ago
The recent changes introduce HTTP/2 support in the HttpClient
through an allowH2
option. This update allows users to enable HTTP/2 when creating HTTP clients, enhancing Server-Sent Events (SSE) support. Modifications span across HttpClient
, HttpAgent
, and corresponding test files, along with README documentation to illustrate the new feature. Additionally, the Node.js workflow in the GitHub Actions configuration has been updated to support more versions.
File | Change Summary |
---|---|
README.md | Added section demonstrating HTTP/2 usage with HttpClient . |
src/HttpAgent.ts |
Introduced allowH2 property in HttpAgentOptions and updated constructor. |
src/HttpClient.ts |
Included allowH2 in ClientOptions and adjusted class instantiation logic. |
test/HttpClient.test.ts |
Added tests for allowH2 and exported getGlobalDispatcher . |
.github/workflows/nodejs.yml |
Corrected and expanded Node.js version list. |
sequenceDiagram
participant User as User
participant Application as Application
participant HttpClient as HttpClient
participant HttpAgent as HttpAgent
participant Server as Server
Note over User, Application: Initial Client Setup
User->>Application: Create HttpClient with allowH2
Application->>HttpClient: New HttpClient({ allowH2: true })
HttpClient->>HttpAgent: Instantiate HttpAgent with allowH2
Note over Application, Server: Making a Request
Application->>HttpClient: Make HTTP request
HttpClient->>HttpAgent: Get Connection
HttpAgent->>Server: Connect (HTTP/2 if supported)
Server->>HttpAgent: Respond
HttpAgent->>HttpClient: Relay Response
HttpClient->>Application: Return Response
Application->>User: Display Results
Objective | Addressed | Explanation |
---|---|---|
Support HTTP2 to make SSE easy [#474] | ✅ |
In the world of bytes and code so spruce,
Comes a client that sips HTTP2 juice.
WithallowH2
, the streams now breeze,
Over the wires where data leads.
From client to server, a path anew,
A rabbit's dream in a world brand new.
🌐🐰🚀
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.86%. Comparing base (
8247aa2
) to head (9b0c129
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
closes https://github.com/node-modules/urllib/issues/474
pick from https://github.com/node-modules/urllib/pull/516
Summary by CodeRabbit
New Features
HttpClient
with the newallowH2
option.getGlobalDispatcher
function for managing global dispatchers.Documentation
HttpClient
.Tests
allowH2
option inHttpClient
.Chores