mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(ext/http): remove unwrap() when HTTP conn errors (#11674)
This commit is contained in:
parent
ebb79b28a5
commit
2937f02f00
2 changed files with 24 additions and 5 deletions
|
@ -731,3 +731,23 @@ unitTest({ perms: { net: true } }, async function httpCookieConcatenation() {
|
||||||
assertEquals(text, "ok");
|
assertEquals(text, "ok");
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://github.com/denoland/deno/issues/11651
|
||||||
|
unitTest({ perms: { net: true } }, async function httpServerPanic() {
|
||||||
|
const listener = Deno.listen({ port: 4501 });
|
||||||
|
const client = await Deno.connect({ port: 4501 });
|
||||||
|
const conn = await listener.accept();
|
||||||
|
const httpConn = Deno.serveHttp(conn);
|
||||||
|
|
||||||
|
// This message is incomplete on purpose, we'll forcefully close client connection
|
||||||
|
// after it's flushed to cause connection to error out on the server side.
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
await client.write(encoder.encode("GET / HTTP/1.1"));
|
||||||
|
|
||||||
|
httpConn.nextRequest();
|
||||||
|
await client.write(encoder.encode("\r\n\r\n"));
|
||||||
|
httpConn.close();
|
||||||
|
|
||||||
|
client.close();
|
||||||
|
listener.close();
|
||||||
|
});
|
||||||
|
|
|
@ -196,13 +196,12 @@ async fn op_http_request_next(
|
||||||
Poll::Ready(Err(e)) => {
|
Poll::Ready(Err(e)) => {
|
||||||
// TODO(ry) close RequestResource associated with connection
|
// TODO(ry) close RequestResource associated with connection
|
||||||
// TODO(ry) close ResponseBodyResource associated with connection
|
// TODO(ry) close ResponseBodyResource associated with connection
|
||||||
// close ConnResource
|
// try to close ConnResource, but don't unwrap as it might
|
||||||
state
|
// already be closed
|
||||||
|
let _ = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.resource_table
|
.resource_table
|
||||||
.take::<ConnResource>(conn_rid)
|
.take::<ConnResource>(conn_rid);
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if should_ignore_error(&e) {
|
if should_ignore_error(&e) {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue