summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/http.ts
AgeCommit message (Collapse)Author
2023-08-28fix(node/http): correctly send `Content-length` header instead of ↵osddeitf
`Transfer-Encoding: chunked` (#20127) Fix #20063.
2023-08-18fix(node/http): emit error when addr in use (#20200)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/20186
2023-08-15perf(ext/node): optimize http headers (#20163)Marcos Casagrande
This PR optimizes Node's `IncomingMessageForServer.headers` by replacing `Object.fromEntries()` with a loop and `headers.entries` with `headersEntries` which returns the internal array directly instead of an iterator ## Benchmarks Using `wrk` with 5 headers ``` wrk -d 10s --latency -H "X-Deno: true" -H "Accept: application/json" -H "X-Foo: bar" -H "User-Agent: wrk" -H "Accept-Encoding: gzip, br" http://127.0.0.1:3000 ``` **this PR** ``` Running 10s test @ http://127.0.0.1:3000 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 167.53us 136.89us 2.75ms 97.33% Req/Sec 31.98k 1.38k 36.39k 70.30% Latency Distribution 50% 134.00us 75% 191.00us 90% 234.00us 99% 544.00us 642548 requests in 10.10s, 45.96MB read Requests/sec: 63620.36 Transfer/sec: 4.55MB ``` **main** ``` Running 10s test @ http://127.0.0.1:3000 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 181.31us 132.54us 3.79ms 97.13% Req/Sec 29.21k 1.45k 32.93k 79.21% Latency Distribution 50% 148.00us 75% 198.00us 90% 261.00us 99% 545.00us 586939 requests in 10.10s, 41.98MB read Requests/sec: 58114.01 Transfer/sec: 4.16MB ``` ```js import express from "npm:express"; const app = express(); app.get("/", function (req, res) { req.headers; res.end(); }); app.listen(3000); ```
2023-08-14perf(ext/node): cache `IncomingMessageForServer.headers` (#20147)Marcos Casagrande
This PR adds caching to node's `req.headers` ```js import express from "npm:express"; const app = express(); app.get("/", function (req, res) { const ua = req.header("User-Agent"); const auth = req.header("Authorization"); const type = req.header("Content-Type"); const ip = req.header("X-Forwarded-For"); res.end(); }); app.listen(3000); ``` **this PR** ``` wrk -d 10s --latency http://127.0.0.1:3000 Running 10s test @ http://127.0.0.1:3000 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 155.64us 152.14us 5.74ms 97.39% Req/Sec 35.00k 1.97k 39.10k 80.69% Latency Distribution 50% 123.00us 75% 172.00us 90% 214.00us 99% 563.00us 703420 requests in 10.10s, 50.31MB read Requests/sec: 69648.45 Transfer/sec: 4.98MB ``` **main** ``` wrk -d 10s --latency http://127.0.0.1:3000 Running 10s test @ http://127.0.0.1:3000 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 217.95us 786.89us 26.26ms 98.23% Req/Sec 32.32k 2.54k 37.19k 87.13% Latency Distribution 50% 130.00us 75% 191.00us 90% 232.00us 99% 1.88ms 649411 requests in 10.10s, 46.45MB read Requests/sec: 64300.44 Transfer/sec: 4.60MB ```
2023-07-25fix(node): add writable and readable fields to FakeSocket (#19931)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19927
2023-07-21fix(node/http): add encrypted field to FakeSocket (#19886)Leo Kettmeir
Fixes #19557
2023-07-19fix(node/http): call callback after request is sent (#19871)Leo Kettmeir
Fixes #19762
2023-07-11fix(node/http): add destroy to FakeSocket (#19796)Leo Kettmeir
Closes #19782
2023-07-11fix(node/http): allow callback in first argument of end call (#19778)Leo Kettmeir
Closes #19762
2023-07-10fix(node/http): server use FakeSocket and add end method (#19660)Leo Kettmeir
Fixes #19324
2023-07-02refactor: rename built-in node modules from ext:deno_node/ to node: (#19680)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19510
2023-06-30fix(node/http): add setKeepAlive to FakeSocket (#19659)Leo Kettmeir
Closes #19535
2023-06-27chore(ext/node): disable prefer-primordials on a per-file basis (#19553)Kenta Moriuchi
2023-06-15refactor(ext/fetch): simplify fetch ops (#19494)Bartek Iwańczuk
Addresses feedback from https://github.com/denoland/deno/pull/19412#discussion_r1227912676
2023-06-14chore(ext/node): bring back changes to ClientRequest.onSocket (#19509)Leo Kettmeir
Reverts denoland/deno#19426
2023-06-13fix(ext/node): handle 'upgrade' responses (#19412)Bartek Iwańczuk
This commit adds support for "upgrade" events in "node:http" "ClientRequest". Currently only "Websocket" upgrades are handled. Thanks to this change package like "npm:puppeteer" and "npm:discord" should work. Closes https://github.com/denoland/deno/issues/18913 Closes https://github.com/denoland/deno/issues/17847
2023-06-13feat(node): HTTPS server (#19362)Leo Kettmeir
2023-06-08chore(ext/node): revert changes to ClientRequest.onSocket (#19426)Bartek Iwańczuk
Partially reverts https://github.com/denoland/deno/pull/19340 because it causes hangs in some situations.
2023-06-06fix(node/http): use fake socket and proper url handling (#19340)Leo Kettmeir
Fixes https://github.com/denoland/deno/issues/19349 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-31refactor: further work on node http client (#19327)Leo Kettmeir
Closes https://github.com/denoland/deno/issues/18300
2023-05-29fix: use proper ALPN protocols if HTTP client is HTTP/1.1 only (#19303)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/16923 --------- Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-05-29fix(node): http.IncomingMessageForClient.complete (#19302)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19238
2023-05-27refactor(node/http): don't use readablestream for writing to request (#19282)Leo Kettmeir
Refactors the internal usage of a readablestream to write to the resource directly --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-24fix(ext/node): ClientRequest.setTimeout(0) should remove listeners (#19240)Levente Kurusa
Co-authored-by: crowlkats <crowlkats@toaxl.com>
2023-05-23refactor: further work on node http client (#19211)Leo Kettmeir
2023-05-22fix(node): add http.Server.unref() (#19201)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19113
2023-05-19BREAKING(unstable): change return type of Deno.serve() API (#19189)Bartek Iwańczuk
This commit changes the return type of an unstable `Deno.serve()` API to instead return a `Deno.Server` object that has a `finished` field. This change is done in preparation to be able to ref/unref the HTTP server.
2023-05-17refactor(node): reimplement http client (#19122)Leo Kettmeir
This commit reimplements most of "node:http" client APIs using "ext/fetch". There is some duplicated code and two removed Node compat tests that will be fixed in follow up PRs. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-02fix(node/http): Request.setTimeout(0) should clear (#18949)Levente Kurusa
Fixes: #18932
2023-04-27refactor(ext/node): migrate back to using "Deno.serve" API for HTTP server ↵Bartek Iwańczuk
(#18865) This commit fixes "node:http" API to properly handle "upgrade" requests and thus marking Vite work again. This is done by migrating back to "Deno.serve()" and internal "upgradeHttpRaw" APIs for "node:http" module polyfill.
2023-04-27fix(ext/http): internal upgradeHttpRaw works with "Deno.serve()" API (#18859)Matt Mastracci
Fix internal "upgradeHttpRaw" API restoring capability to upgrade HTTP connection in polyfilles "node:http" API.
2023-04-22feat(node/http): implement ClientRequest.setTimeout() (#18783)Levente Kurusa
- implement setTimeout with matching semantics of Node - add the test from Node but leave it turned off because ClientRequest has no underlying socket
2023-04-18fix(ext/node): add req.socket.remoteAddress (#18733)Yoshiya Hinosawa
2023-04-18fix(ext/node): polyfill response._implicitHeader method (#18738)Yoshiya Hinosawa
2023-04-07refactor(ext/node): remove conditional in ServerResponse#enqueue (#18617)Bartek Iwańczuk
It's superfluous, the issue linked is no longer relevant. Closes https://github.com/denoland/deno/issues/18579
2023-04-03refactor(ext/node): migrate "http" module to use "Deno.serveHttp" API (#18552)Bartek Iwańczuk
This commit changes "node:http" module to use "Deno.serveHttp" API instead of "Deno.serve" API. --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2023-03-28Reland "refactor: remove Deno[Deno.internal].nodeUnstable namespace" (#18475)Bartek Iwańczuk
This reverts commit 357bcfcf79fee92195e37bb3f05e247908f207c5.
2023-03-27Revert "refactor: remove Deno[Deno.internal].nodeUnstable namespace (… ↵Bartek Iwańczuk
(#18458) …#18449)" This reverts commit d1a9c4cd7ce0c19ddf9c7c52c0d35d6124a7677d. Appears this made CI very flaky on macOS, but I can't repeat it locally yet
2023-03-27refactor: remove Deno[Deno.internal].nodeUnstable namespace (#18449)Bartek Iwańczuk
Since we can preserve ops in the snapshot these days, we no longer need to have "Deno[Deno.internal].nodeUnstable" namespace. Instead, various built-in Node.js modules can use appropriate APIs directly.
2023-03-08refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme ↵Bartek Iwańczuk
for snapshotted modules (#18041) This commit renames "deno_core::InternalModuleLoader" to "ExtModuleLoader" and changes the specifiers used by the modules loaded from this loader to "ext:". "internal:" scheme was really ambiguous and it's more characters than "ext:", which should result in slightly smaller snapshot size. Closes https://github.com/denoland/deno/issues/18020
2023-03-05refactor(core): include_js_files! 'dir' option doesn't change specifiers ↵Bartek Iwańczuk
(#18019) This commit changes "include_js_files!" macro from "deno_core" in a way that "dir" option doesn't cause specifiers to be rewritten to include it. Example: ``` include_js_files! { dir "js", "hello.js", } ``` The above definition required embedders to use: `import ... from "internal:<ext_name>/js/hello.js"`. But with this change, the "js" directory in which the files are stored is an implementation detail, which for embedders results in: `import ... from "internal:<ext_name>/hello.js"`. The directory the files are stored in, is an implementation detail and in some cases might result in a significant size difference for the snapshot. As an example, in "deno_node" extension, we store the source code in "polyfills" directory; which resulted in each specifier to look like "internal:deno_node/polyfills/<module_name>", but with this change it's "internal:deno_node/<module_name>". Given that "deno_node" has over 100 files, many of them having several import specifiers to the same extension, this change removes 10 characters from each import specifier.
2023-02-14feat(ext/node): embed std/node into the snapshot (#17724)Bartek Iwańczuk
This commit moves "deno_std/node" in "ext/node" crate. The code is transpiled and snapshotted during the build process. During the first pass a minimal amount of work was done to create the snapshot, a lot of code in "ext/node" depends on presence of "Deno" global. This code will be gradually fixed in the follow up PRs to migrate it to import relevant APIs from "internal:" modules. Currently the code from snapshot is not used in any way, and all Node/npm compatibility still uses code from "https://deno.land/std/node" (or from the location specified by "DENO_NODE_COMPAT_URL"). This will also be handled in a follow up PRs. --------- Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com> Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>