1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-11 10:07:54 -05:00
This commit is contained in:
Yoshiya Hinosawa 2024-09-26 13:31:06 +09:00
parent a32ea23dea
commit 33c4efac51
No known key found for this signature in database
GPG key ID: 9017DB4559488785
2 changed files with 126 additions and 125 deletions

View file

@ -333,7 +333,10 @@ pub fn take_network_stream_resource(
if let Ok(resource_rc) = resource_table.take::<TcpStreamResource>(stream_rid) if let Ok(resource_rc) = resource_table.take::<TcpStreamResource>(stream_rid)
{ {
// This TCP connection might be used somewhere else. // This TCP connection might be used somewhere else.
let resource: crate::io::FullDuplexResource<tokio::net::tcp::OwnedReadHalf, tokio::net::tcp::OwnedWriteHalf> = Rc::try_unwrap(resource_rc) let resource: crate::io::FullDuplexResource<
tokio::net::tcp::OwnedReadHalf,
tokio::net::tcp::OwnedWriteHalf,
> = Rc::try_unwrap(resource_rc)
.map_err(|_| bad_resource("TCP stream is currently in use"))?; .map_err(|_| bad_resource("TCP stream is currently in use"))?;
let (read_half, write_half) = resource.into_inner(); let (read_half, write_half) = resource.into_inner();
let tcp_stream = read_half.reunite(write_half)?; let tcp_stream = read_half.reunite(write_half)?;

View file

@ -452,10 +452,9 @@ Deno.test("[node/http] http.IncomingMessage can be created without url", () => {
}); });
*/ */
Deno.test( Deno.test("[node/http] send request with non-chunked body", {
"[node/http] send request with non-chunked body", ignore: true,
{ ignore: true }, }, async () => {
async () => {
let requestHeaders: Headers; let requestHeaders: Headers;
let requestBody = ""; let requestBody = "";
@ -512,8 +511,7 @@ Deno.test(
// in order to not cause a flaky test sanitizer failure // in order to not cause a flaky test sanitizer failure
await new Promise((resolve) => setTimeout(resolve, 100)), await new Promise((resolve) => setTimeout(resolve, 100)),
]); ]);
}, });
);
Deno.test("[node/http] send request with chunked body", async () => { Deno.test("[node/http] send request with chunked body", async () => {
let requestHeaders: Headers; let requestHeaders: Headers;
@ -694,10 +692,9 @@ Deno.test("[node/http] ClientRequest handle non-string headers", {
assertEquals(headers!["1"], "2"); assertEquals(headers!["1"], "2");
}); });
Deno.test( Deno.test("[node/http] ClientRequest uses HTTP/1.1", {
"[node/http] ClientRequest uses HTTP/1.1", ignore: true,
{ ignore: true }, }, async () => {
async () => {
let body = ""; let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>(); const { promise, resolve, reject } = Promise.withResolvers<void>();
const req = https.request("https://localhost:5545/http_version", { const req = https.request("https://localhost:5545/http_version", {
@ -717,8 +714,7 @@ Deno.test(
await promise; await promise;
console.log(body); console.log(body);
assertEquals(body, "HTTP/1.1"); assertEquals(body, "HTTP/1.1");
}, });
);
Deno.test("[node/http] ClientRequest setTimeout", async () => { Deno.test("[node/http] ClientRequest setTimeout", async () => {
let body = ""; let body = "";
@ -806,10 +802,9 @@ Deno.test("[node/http] ClientRequest PUT", async () => {
assertEquals(body, "hello world"); assertEquals(body, "hello world");
}); });
Deno.test( Deno.test("[node/http] ClientRequest search params", {
"[node/http] ClientRequest search params", ignore: true,
{ ignore: true }, }, async () => {
async () => {
let body = ""; let body = "";
const { promise, resolve, reject } = Promise.withResolvers<void>(); const { promise, resolve, reject } = Promise.withResolvers<void>();
const req = http.request({ const req = http.request({
@ -828,8 +823,7 @@ Deno.test(
req.end(); req.end();
await promise; await promise;
assertEquals(body, "foo=bar"); assertEquals(body, "foo=bar");
}, });
);
Deno.test("[node/http] HTTPS server", async () => { Deno.test("[node/http] HTTPS server", async () => {
const deferred = Promise.withResolvers<void>(); const deferred = Promise.withResolvers<void>();
@ -1025,7 +1019,9 @@ Deno.test(
Deno.test( Deno.test(
"[node/http] client destroy before sending request should not error", "[node/http] client destroy before sending request should not error",
{ ignore: true }, {
ignore: true,
},
() => { () => {
const request = http.request("http://localhost:5929/"); const request = http.request("http://localhost:5929/");
// Calling this would throw // Calling this would throw
@ -1033,10 +1029,9 @@ Deno.test(
}, },
); );
Deno.test( Deno.test("[node/http] destroyed requests should not be sent", {
"[node/http] destroyed requests should not be sent", ignore: true,
{ ignore: true }, }, async () => {
async () => {
let receivedRequest = false; let receivedRequest = false;
const server = Deno.serve(() => { const server = Deno.serve(() => {
receivedRequest = true; receivedRequest = true;
@ -1049,8 +1044,7 @@ Deno.test(
await new Promise((r) => setTimeout(r, 500)); await new Promise((r) => setTimeout(r, 500));
assertEquals(receivedRequest, false); assertEquals(receivedRequest, false);
await server.shutdown(); await server.shutdown();
}, });
);
Deno.test("[node/http] node:http exports globalAgent", async () => { Deno.test("[node/http] node:http exports globalAgent", async () => {
const http = await import("node:http"); const http = await import("node:http");
@ -1078,7 +1072,9 @@ Deno.test("[node/https] node:https exports globalAgent", async () => {
Deno.test( Deno.test(
"[node/http] node:http request.setHeader(header, null) doesn't throw", "[node/http] node:http request.setHeader(header, null) doesn't throw",
{ ignore: true }, {
ignore: true,
},
() => { () => {
{ {
const req = http.request("http://localhost:4545/"); const req = http.request("http://localhost:4545/");
@ -1634,7 +1630,9 @@ Deno.test("[node/http] In ClientRequest, option.hostname has precedence over opt
Deno.test( Deno.test(
"[node/http] upgraded socket closes when the server closed without closing handshake", "[node/http] upgraded socket closes when the server closed without closing handshake",
{ ignore: true }, {
ignore: true,
},
async () => { async () => {
const clientSocketClosed = Promise.withResolvers<void>(); const clientSocketClosed = Promise.withResolvers<void>();
const serverProcessClosed = Promise.withResolvers<void>(); const serverProcessClosed = Promise.withResolvers<void>();