Skip to content

feat: add IP prioritization hints for HTTP/1.1 and HTTP/2#4831

Open
amyssnippet wants to merge 1 commit intonodejs:mainfrom
amyssnippet:main
Open

feat: add IP prioritization hints for HTTP/1.1 and HTTP/2#4831
amyssnippet wants to merge 1 commit intonodejs:mainfrom
amyssnippet:main

Conversation

@amyssnippet
Copy link

This relates to...

IP Prioritization support for HTTP/1.1 and HTTP/2 requests.

Rationale

This PR introduces the ability to set IP-level prioritization hints for requests. This is particularly useful for applications running in environments that utilize Quality of Service (QoS) markings or differentiated services (DiffServ) at the network layer, allowing for fine-grained control over packet priority directly from the HTTP client.

Changes

  • lib/core/request.js: Updated the Request constructor to accept a hints option (validated as a number).
  • lib/dispatcher/client-h1.js: Updated the HTTP/1.1 dispatcher to apply the hints value to the socket using socket.setPriority() if available.
  • lib/core/connect.js: Verified that hints are passed through buildConnector to net.connect options.
  • types/dispatcher.d.ts & types/connector.d.ts: Added TypeScript definitions for the hints option.
  • test/ip-prioritization.js: Added new tests to verify:
    • socket.setPriority is called with the correct value for HTTP/1.1.
    • hints are correctly passed to the connection options (net.connect) for HTTP/2.

Features

  • Added support for hints in DispatchOptions to set IP prioritization.
  • Supported for both HTTP/1.1 (per-request via socket.setPriority) and HTTP/2 (per-connection via connect options).

Bug Fixes

N/A

Breaking Changes and Deprecations

N/A

Status

@amyssnippet
Copy link
Author

@ronag , after the merge of the nodejs/node#61503 , i saw this reference and i thought to contribute here too.
kindly review the changes

}

if (socket.setPriority) {
socket.setPriority(request.hints)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What API is this?

@metcoder95
Copy link
Member

Is not the same API as the one added in the upstream PR

Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hints is imho a too generic term. We should need a more specific term.
If I understand you correctly you want to pass the value down as typeOfService

So i guess hints has to be renamed to typeOfService and setPriority to setTypeOfService ?

Also typeOfService has to be a number between 0 and 255?

I

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.

4 participants