feat(http): add HTTP2 support; (#7150)#1
Open
MitchLewis930 wants to merge 1 commit intopr_021_beforefrom
Open
Conversation
Author
Greptile OverviewGreptile SummaryThis PR adds experimental HTTP2 support to the http adapter with session pooling and reuse capabilities. The implementation introduces a new Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant httpAdapter
participant Http2Sessions
participant http2Transport
participant HTTP2Session
participant Server
Client->>httpAdapter: axios.request({httpVersion: 2})
httpAdapter->>httpAdapter: validate httpVersion (1 or 2)
httpAdapter->>httpAdapter: setup abort handlers
alt HTTP2 Mode
httpAdapter->>http2Transport: transport.request(options, callback)
http2Transport->>http2Transport: build authority (protocol://hostname:port)
http2Transport->>Http2Sessions: getSession(authority, http2Options)
alt Session exists and valid
Http2Sessions->>Http2Sessions: check existing sessions
Http2Sessions->>Http2Sessions: match by authority & options
Http2Sessions-->>http2Transport: return existing session
else Create new session
Http2Sessions->>HTTP2Session: connect(authority, options)
HTTP2Session-->>Http2Sessions: new session
Http2Sessions->>HTTP2Session: setTimeout(sessionTimeout)
Http2Sessions->>Http2Sessions: store session
Http2Sessions-->>http2Transport: return new session
end
http2Transport->>http2Transport: build HTTP2 headers
http2Transport->>HTTP2Session: session.request(http2Headers)
HTTP2Session->>Server: HTTP2 stream request
Server-->>HTTP2Session: response headers
HTTP2Session-->>http2Transport: emit 'response' event
http2Transport->>http2Transport: set response.statusCode
http2Transport-->>httpAdapter: callback(response)
httpAdapter->>httpAdapter: process response stream
Server-->>HTTP2Session: response data chunks
HTTP2Session-->>httpAdapter: data chunks
httpAdapter->>httpAdapter: decompress if needed
httpAdapter->>httpAdapter: handle progress events
alt responseType: 'stream'
httpAdapter-->>Client: resolve with stream
else buffer response
httpAdapter->>httpAdapter: collect chunks
httpAdapter->>httpAdapter: convert to responseType
httpAdapter-->>Client: resolve with data
end
alt Session timeout
HTTP2Session->>HTTP2Session: timeout after sessionTimeout ms
HTTP2Session->>HTTP2Session: close()
HTTP2Session->>Http2Sessions: emit 'close'
Http2Sessions->>Http2Sessions: remove from sessions
end
else HTTP1 Mode
httpAdapter->>Server: http/https.request()
Server-->>httpAdapter: response
httpAdapter-->>Client: resolve with response
end
|
|
|
||
| const http2Transport = { | ||
| request(options, cb) { | ||
| const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 80); |
There was a problem hiding this comment.
default port should be 443 for HTTPS (HTTP2 is typically over HTTPS)
Suggested change
| const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 80); | |
| const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 443); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/adapters/http.js
Line: 239:239
Comment:
default port should be 443 for HTTPS (HTTP2 is typically over HTTPS)
```suggestion
const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 443);
```
How can I resolve this? If you propose a fix, please make it concise.
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.
PR_021