Skip to content
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(ext/node): migrate "http" module to use "Deno.serveHttp" API #18552

Merged
merged 28 commits into from
Apr 2, 2023

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Apr 1, 2023

This commit changes "node:http" module to use "Deno.serveHttp" API instead of
"Deno.serve" API. This allows us to migrate "Deno.serve" API to use "Deno.serveHttp"
under the hood and by extension allows us to remove the "flash" server implementation.

@bartlomieju bartlomieju marked this pull request as draft April 1, 2023 15:58
@bartlomieju bartlomieju mentioned this pull request Apr 2, 2023
@bartlomieju bartlomieju changed the title [WIP] refactor(ext/node): migrate "http" module to use "Deno.serveHttp" API refactor(ext/node): migrate "http" module to use "Deno.serveHttp" API Apr 2, 2023
@bartlomieju bartlomieju marked this pull request as ready for review April 2, 2023 21:30
Comment on lines +673 to +686
if (req.upgrade && this.listenerCount("upgrade") > 0) {
const conn = await denoHttp.upgradeHttpRaw(
reqEvent.request,
tcpConn,
) as Deno.Conn;
const socket = new Socket({
handle: new TCP(constants.SERVER, conn),
});
this.emit("upgrade", req, socket, Buffer.from([]));
return;
} else {
const res = new ServerResponse(reqEvent);
this.emit("request", req, res);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Is there an immutable node buffer we can use to avoid allocating? It's only on connection so probably isn't a huge deal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about that. Are you talking about the Buffer.from([])?

Copy link
Contributor

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Lots of code gone!

@bartlomieju bartlomieju merged commit 3cd7abf into denoland:main Apr 2, 2023
@bartlomieju bartlomieju deleted the http_upgrade branch April 2, 2023 22:50
levex pushed a commit that referenced this pull request Apr 12, 2023
…#18552)

This commit changes "node:http" module to use "Deno.serveHttp" API
instead of "Deno.serve" API.

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants