mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
fix: use proper ALPN protocols if HTTP client is HTTP/1.1 only (#19303)
Closes https://github.com/denoland/deno/issues/16923 --------- Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
parent
fc6ba92024
commit
d90a75c036
6 changed files with 81 additions and 4 deletions
|
@ -151,7 +151,8 @@
|
|||
"test-dns-promises-resolve.js",
|
||||
"test-dns-regress-6244.js",
|
||||
"test-dns-setserver-in-callback-of-resolve4.js",
|
||||
"test-dns.js"
|
||||
"test-dns.js",
|
||||
"test-http-https-default-ports.js"
|
||||
],
|
||||
"parallel": [
|
||||
"test-assert-async.js",
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// deno-fmt-ignore-file
|
||||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const { addresses } = require('../common/internet');
|
||||
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const https = require('https');
|
||||
|
||||
const http = require('http');
|
||||
|
||||
https.get(`https://${addresses.INET_HOST}/`, common.mustCall((res) => {
|
||||
res.resume();
|
||||
}));
|
||||
|
||||
http.get(`http://${addresses.INET_HOST}/`, common.mustCall((res) => {
|
||||
res.resume();
|
||||
}));
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import EventEmitter from "node:events";
|
||||
import http, { type RequestOptions } from "node:http";
|
||||
import https from "node:https";
|
||||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
|
@ -509,3 +510,24 @@ Deno.test("[node/http] ClientRequest handle non-string headers", async () => {
|
|||
await def;
|
||||
assertEquals(headers!["1"], "2");
|
||||
});
|
||||
|
||||
Deno.test("[node/http] ClientRequest uses HTTP/1.1", async () => {
|
||||
let body = "";
|
||||
const def = deferred();
|
||||
const req = https.request("https://localhost:5545/http_version", {
|
||||
method: "POST",
|
||||
headers: { 1: 2 },
|
||||
}, (resp) => {
|
||||
resp.on("data", (chunk) => {
|
||||
body += chunk;
|
||||
});
|
||||
|
||||
resp.on("end", () => {
|
||||
def.resolve();
|
||||
});
|
||||
});
|
||||
req.once("error", (e) => def.reject(e));
|
||||
req.end();
|
||||
await def;
|
||||
assertEquals(body, "HTTP/1.1");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue