1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-01 16:51:13 -05:00

workaround ipv4 vs ipv6 issues for windows by specifying ip address instead of localhost in problematic situation

This commit is contained in:
Yoshiya Hinosawa 2024-10-18 20:48:09 +09:00
parent 5b4aa79fb6
commit 84e1d84bb6
No known key found for this signature in database
GPG key ID: 9017DB4559488785

View file

@ -460,7 +460,8 @@ Deno.test("[node/http] send request with non-chunked body", async () => {
let requestHeaders: Headers;
let requestBody = "";
const hostname = "localhost";
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const hostname = "127.0.0.1";
const port = 4505;
const handler = async (req: Request) => {
@ -517,7 +518,8 @@ Deno.test("[node/http] send request with chunked body", async () => {
let requestHeaders: Headers;
let requestBody = "";
const hostname = "localhost";
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const hostname = "127.0.0.1";
const port = 4505;
const handler = async (req: Request) => {
@ -564,7 +566,8 @@ Deno.test("[node/http] send request with chunked body as default", async () => {
let requestHeaders: Headers;
let requestBody = "";
const hostname = "localhost";
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const hostname = "127.0.0.1";
const port = 4505;
const handler = async (req: Request) => {
@ -670,6 +673,7 @@ Deno.test("[node/http] ClientRequest handle non-string headers", async () => {
// deno-lint-ignore no-explicit-any
let headers: any;
const { promise, resolve, reject } = Promise.withResolvers<void>();
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const req = http.request("http://127.0.0.1:4545/echo_server", {
method: "POST",
headers: { 1: 2 },
@ -713,6 +717,7 @@ Deno.test("[node/http] ClientRequest setTimeout", async () => {
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();
const timer = setTimeout(() => reject("timed out"), 50000);
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const req = http.request("http://127.0.0.1:4545/http_version", (resp) => {
resp.on("data", (chunk) => {
body += chunk;
@ -734,6 +739,7 @@ Deno.test("[node/http] ClientRequest setNoDelay", async () => {
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();
const timer = setTimeout(() => reject("timed out"), 50000);
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const req = http.request("http://127.0.0.1:4545/http_version", (resp) => {
resp.on("data", (chunk) => {
body += chunk;
@ -754,6 +760,7 @@ Deno.test("[node/http] ClientRequest setNoDelay", async () => {
Deno.test("[node/http] ClientRequest PATCH", async () => {
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const req = http.request("http://127.0.0.1:4545/echo_server", {
method: "PATCH",
}, (resp) => {
@ -776,6 +783,7 @@ Deno.test("[node/http] ClientRequest PATCH", async () => {
Deno.test("[node/http] ClientRequest PUT", async () => {
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const req = http.request("http://127.0.0.1:4545/echo_server", {
method: "PUT",
}, (resp) => {
@ -799,6 +807,7 @@ Deno.test("[node/http] ClientRequest search params", async () => {
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();
const req = http.request({
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
host: "127.0.0.1",
port: 4545,
path: "/search_params?foo=bar",
@ -925,6 +934,7 @@ Deno.test(
let body = "";
const request = http.request(
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
"http://127.0.0.1:5928/",
(resp) => {
resp.on("data", (chunk) => {
@ -993,6 +1003,7 @@ Deno.test(
);
const { promise, resolve, reject } = Promise.withResolvers<void>();
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const request = http.request("http://127.0.0.1:5929/");
request.on("error", reject);
request.on("close", () => {});
@ -1013,6 +1024,7 @@ Deno.test(
"[node/http] client destroy before sending request should not error",
async () => {
const { resolve, promise } = Promise.withResolvers<void>();
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const request = http.request("http://localhost:5929/");
// Calling this would throw
request.destroy();
@ -1569,6 +1581,7 @@ Deno.test("[node/http] ClientRequest PUT subarray", async () => {
const payload = buffer.subarray(6, 11);
let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>();
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const req = http.request("http://127.0.0.1:4545/echo_server", {
method: "PUT",
}, (resp) => {
@ -1609,6 +1622,7 @@ Deno.test("[node/http] ClientRequest content-disposition header works", async ()
let body = "";
let headers = {} as http.IncomingHttpHeaders;
const { promise, resolve, reject } = Promise.withResolvers<void>();
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
const req = http.request("http://127.0.0.1:4545/echo_server", {
method: "PUT",
headers: {
@ -1635,6 +1649,7 @@ Deno.test("[node/http] In ClientRequest, option.hostname has precedence over opt
const responseReceived = Promise.withResolvers<void>();
new http.ClientRequest({
// TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net
hostname: "127.0.0.1",
host: "invalid-hostname.test",
port: 4545,