Skip to content

feat(api): add Response.httpVersion() method#39434

Open
smckee-r7 wants to merge 3 commits intomicrosoft:mainfrom
smckee-r7:response-http-version
Open

feat(api): add Response.httpVersion() method#39434
smckee-r7 wants to merge 3 commits intomicrosoft:mainfrom
smckee-r7:response-http-version

Conversation

@smckee-r7
Copy link

@smckee-r7 smckee-r7 commented Feb 26, 2026

Adds Response.httpVersion() to get the http version of a given response.
Issue: #39310

Previous PR #39309 was closed out with some comments. I've addressed the comments and opened a this new PR. This feature would be extremely useful to reduce bloat/boilerplate for our test suite.

Copy link
Member

@yury-s yury-s left a comment

Choose a reason for hiding this comment

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

The PR still has too many issues and lacking any tests. Unfortunately, I don't see it converging.

if (httpVersion === 'h2')
return 'HTTP/2.0';
return this._httpVersion;
if (httpVersion === 'h3')
Copy link
Member

Choose a reason for hiding this comment

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

this does not improve things and just adds confusion, don't change it

this._getResponseBodyCallback = getResponseBodyCallback;
this._request._setResponse(this);
this._httpVersion = httpVersion;
if (httpVersion)
Copy link
Member

Choose a reason for hiding this comment

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

only one client has it ready right away, make it call the new setter and remove the param

}

private _onResponse(response: network.Response) {
private async _onResponse(response: network.Response) {
Copy link
Member

Choose a reason for hiding this comment

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

we don't want async event handlers

async httpVersion(): Promise<string> {
return this._wrapApiCall(async () => {
return (await this._channel.httpVersion()).value;
}, { internal: true });
Copy link
Member

Choose a reason for hiding this comment

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

why do you have this here while it's already defined in the protocol yaml?

Copy link
Author

Choose a reason for hiding this comment

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

Your 100% right, my bad, I naively dived into this PR before understanding enough and misunderstood the architecture. Once I found the protocol.yml I added the definition there, but forgot to revert this change

@smckee-r7
Copy link
Author

The PR still has too many issues and lacking any tests. Unfortunately, I don't see it converging.

I've hopefully resolved your comments and added a basic test. I'm willing get this to a place you guys are happy with but if that's never going to happen, feel free to close the PR. However, not having this feature would be a shame since the only way to assert the httpVersion using HAR recording is currently awkward/heavy

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