Skip to content

Commit be237c5

Browse files
committed
fix(client): HTTP/2 should use hostname in URL as host instead of remoteHost
1 parent 6f21534 commit be237c5

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes Logs
22

3+
## v1.0.4
4+
5+
- fix(client): HTTP/2 should use hostname in URL as host instead of `remoteHost`
6+
37
## v1.0.3
48

59
- fix(client): Apply timeout for response stream.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@litert/http-client",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A simple HTTP client based on LiteRT.",
55
"main": "lib/index.js",
66
"dependencies": {

src/lib/Internal/AbstractHttp2Client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ export abstract class AbstractHttp2Client extends AbstractProtocolClient {
206206
[$H2.constants.HTTP2_HEADER_PATH]: this._.buildPath(opts.url)
207207
};
208208

209-
if (opts.connectionOptions.remoteHost) {
209+
if (!headers[$H2.constants.HTTP2_HEADER_AUTHORITY]) {
210210

211-
opts.connectionOptions.servername = opts.url.hostname;
212-
opts.url.hostname = opts.connectionOptions.remoteHost;
211+
headers[$H2.constants.HTTP2_HEADER_AUTHORITY] = opts.url.hostname;
213212
}
214213

215-
if (!headers[$H2.constants.HTTP2_HEADER_AUTHORITY]) {
214+
if (opts.connectionOptions.remoteHost) {
216215

217-
headers[$H2.constants.HTTP2_HEADER_AUTHORITY] = opts.url.hostname;
216+
opts.connectionOptions.servername = opts.url.hostname;
217+
opts.url.hostname = opts.connectionOptions.remoteHost;
218218
}
219219

220220
const [connId, conn] = await this._getConnection(

0 commit comments

Comments
 (0)