-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: "Deno.serve()" API uses "Deno.serveHttp()" internally #18568
Conversation
@@ -301,51 +301,6 @@ Deno.test( | |||
}, | |||
); | |||
|
|||
Deno.test( | |||
{ permissions: { net: true } }, | |||
async function httpReadHeadersAfterClose() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer necessary. Deno.serveHttp()
returns properly formed response (ie. it doesn't do lazy loading of data), so headers are still available after the connection has been closed. This will allow us to remove some code in ext/fetch/23_request.js
cli/tests/unit/flash_test.ts
Outdated
// https://github.com/denoland/deno/issues/17291 | ||
Deno.test( | ||
{ permissions: { net: true } }, | ||
{ permissions: { net: true }, ignore: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@littledivy please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears this test was broken as well - there's no problem pushing strings to a ReadableStream
, unless it has type: "bytes"
@@ -1122,68 +1079,6 @@ Deno.test( | |||
}, | |||
); | |||
|
|||
Deno.test("upgradeHttpRaw tcp", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unstable API will be removed along with flash implementation. Effectively there's no way to test it and the API will always throw.
cli/tests/unit/flash_test.ts
Outdated
Deno.test( | ||
{ permissions: { net: true } }, | ||
{ permissions: { net: true }, ignore: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@littledivy please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this test requires Content-Length: 0
for the HEAD requests. It appears Hyper is not doing that and it's not mandatory to send this header. Can we remove this test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be any need for a zero Content-Length
header, implicit or explicit. Does node
have one? Even then, that's probably better to keep in the polyfill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think test changes are very reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think the cookie coalescing behaviour is not correct. Using ;
as a cookie separator is correct, but using it as a header separator is not correct. The header separator is always ,
. Multiple headers with the same name may be coalesced together using the ,
(except set-cookie
, which is special cased). This behaviour must not be different for cookie
headers.
It is possible that this is a bug in fetch
. If it is, we can fix it in a different PR. We need to have a test that the wire representation of the below response is either cookie: foo=bar\r\ncookie: bar=foo\r\n
or cookie: foo=bar, bar=foo\r\n
, but not cookie: foo=bar; bar=foo\r\n
.
const h = new Headers();
h.append("cookie", "foo=bar");
h.append("cookie", "bar=foo");
console.log(h.get("cookie")); // "foo=bar, bar=foo"
new Response("", { headers: h })
The fetch spec requires that Headers
objects do not treat cookie
specially, and it mandates that any coalescing of headers must use ,
.
Also we should have a test where we send the HTTP server a request using something other than fetch (ideally a hand-written H1 request), with definitely not coalesced |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retracting my request-changes, because this behaviour is already the case with serveHttp
. See
Lines 555 to 560 in 6d68392
// We treat cookies specially, because we don't want them to get them | |
// mangled by the `Headers` object in JS. What we do is take all cookie | |
// headers and concat them into a single cookie header, separated by | |
// semicolons. | |
let cookie_sep = "; ".as_bytes(); | |
let mut cookies = vec![]; |
Does this solve #16267? |
This commit changes implementation of "Deno.serve()" API to use "Deno.serveHttp()" under the hood. This change will allow us to remove the "flash" server implementation, bringing stability to the "Deno.serve()" API. "cli/tests/unit/flash_test.ts" was renamed to "serve_test.ts". Closes #15574 Closes #15504 Closes #15646 Closes #15909 Closes #15911 Closes #16828 Closes #18046 Closes #15869
This commit changes implementation of "Deno.serve()" API to use
"Deno.serveHttp()" under the hood. This change will allow us to
remove the "flash" server implementation, bringing stability to the
"Deno.serve()" API.
"cli/tests/unit/flash_test.ts" was renamed to "serve_test.ts".
Closes #15574
Closes #15504
Closes #15646
Closes #15909
Closes #15911
Closes #16828
Closes #18046
Closes #15869