summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/http.ts
AgeCommit message (Collapse)Author
2024-10-30fix(ext/node): return `this` from `http.Server.ref/unref()` (#26647)Nathan Whitaker
Fixes https://github.com/denoland/deno/issues/26642
2024-10-29Revert "fix(ext/node): fix dns.lookup result ordering (#26264)" (#26621)Yoshiya Hinosawa
This reverts commit d59599fc187c559ee231882773e1c5a2b932fc3d. Closes #26588
2024-10-25fix(ext/node): refactor http.ServerResponse into function class (#26210)Nicola Bovolato
While testing, I found out that light-my-request relies on `ServerResponse.connection`, which is deprecated, so I added that and `socket`, the non deprecated property. It also relies on an undocumented `_header` property, apparently for [raw header processing](https://github.com/fastify/light-my-request/blob/v6.1.0/lib/response.js#L180-L186). I added it as an empty string, feel free to provide other approaches. Fixes #19901 Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-10-17fix(net): don't try to set nodelay on upgrade streams (#26342)Nathan Whitaker
Fixes https://github.com/denoland/deno/issues/26341. We try to call `op_set_nodelay` on an `UpgradeStream`, which doesn't support that operation.
2024-10-17fix(node/http): normalize header names in `ServerResponse` (#26339)Nathan Whitaker
Fixes https://github.com/denoland/deno/issues/26115. We weren't normalizing the headers to lower case, so code that attempted to delete the `Content-Length` header (but used a different case) wasn't actually removing the header.
2024-10-16fix(ext/node): fix dns.lookup result ordering (#26264)Yoshiya Hinosawa
partially unblocks #25470 This PR aligns the resolution of `localhost` hostname to Node.js behavior. In Node.js `dns.lookup("localhost", (_, addr) => console.log(addr))` prints ipv6 address `::1`, but it prints ipv4 address `127.0.0.1` in Deno. That difference causes some errors in the work of enabling `createConnection` option in `http.request` (#25470). This PR fixes the issue by aligning `dns.lookup` behavior to Node.js. This PR also changes the following behaviors (resolving TODOs): - `http.createServer` now listens on ipv6 address `[::]` by default on linux/mac - `net.createServer` now listens on ipv6 address `[::]` by default on linux/mac These changes are also alignments to Node.js behaviors.
2024-09-12feat(ext/node): expose ES modules for _ modules (#25588)Bartek Iwańczuk
Exposes following modules: - `"node:_http_agent"` - `"node:_http_common"` - `"node:_http_outgoing"` - `"node:_http_server"` - `"node:_stream_duplex"` - `"node:_stream_passthrough"` - `"node:_stream_readable"` - `"node:_stream_transform"` - `"node:_stream_writable"` - `"node:_tls_common"` - `"node:_tls_wrap"`
2024-08-21fix(ext/node): pass content-disposition header as string instead of bytes ↵Satya Rohith
(#25128) Closes https://github.com/denoland/deno/issues/25117
2024-08-20chore: enable no-console dlint rule (#25113)David Sherret
2024-08-18fix(node/http): wrong `req.url` value (#25081)Marvin Hagemeister
This PR addresses a regression introduced in https://github.com/denoland/deno/pull/25021 that would cause the `req.url` parameter in Node's http server to always be a single character instead of the expected value. The regression was caused by effectively calling `.indexOf()` on an empty string and thus passing the wrong index for slicing. ```js "".indexOf("/") // -> -1 request.url.slice(-1) // effectively only giving us the last character ``` Fixes https://github.com/denoland/deno/issues/25080
2024-08-14fix: dd-trace http message compat (#25021)snek
make this http incoming constructor match with node, and also handle arbitrary duplex inputs
2024-08-12fix(ext/node): don't concat set-cookie in ServerResponse.appendHeader (#25000)Luca Casonato
Follow-on to https://github.com/denoland/deno/pull/24216/files#r1642188672
2024-08-08fix(ext/node): client closing streaming request shouldn't terminate http ↵Satya Rohith
server (#24946) Closes https://github.com/denoland/deno/issues/22820
2024-07-30refactor(ext/node): create separate ops for node:http module (#24788)Bartek Iwańczuk
This commit duplicates ops from "ext/fetch" to "ext/node" to kick off a bigger rewrite of "node:http". Most of duplication is temporary and will be removed as these ops evolve.
2024-07-10fix(node/http): don't send destroyed requests (#24498)Marvin Hagemeister
Make sure that already destroyed requests are not actually sent. This error was discovered in jsdom's test suite.
2024-07-10fix(node/http): don't error if request destroyed before send (#24497)Marvin Hagemeister
A request can be destroyed before it was even made in the Node http API. We errored on that. This issue was discovered in the JSDOM test suite.
2024-07-09fix(node/http): support all `.writeHead()` signatures (#24469)Marvin Hagemeister
Implement the missing `.writeHead()` signatures from Node's `ServerResponse` class that we didn't support. Fixes https://github.com/denoland/deno/issues/24468
2024-07-05chore: remove unused class private properties (#24441)Marvin Hagemeister
Noticed that these private class properties are never used. Maybe a leftover from an earlier implementation.
2024-07-05fix(ext/node): http chunked writes hangs (#24428)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/24239
2024-07-04fix(node/http): don't throw on .address() before .listen() (#24432)Marvin Hagemeister
It's perfectly valid to access `server.address()` before calling `.listen()`. Until a server actively listens on a socket Node will return `null` here, but we threw a "Cannot access property 'port' of undefined" instead. This was discovered when inspecting failures in Koa's test suite with Deno.
2024-07-03fix(ext/node): don't wait for end() call to send http client request (#24390)Satya Rohith
Closes https://github.com/denoland/deno/issues/24232 Closes https://github.com/denoland/deno/issues/24215
2024-06-25fix(ext/node): ignore stream error during enqueue (#24243)Satya Rohith
2024-06-21fix(ext/node): add ServerResponse#appendHeader (#24216)Divy Srivastava
2024-06-14fix(ext/node): `server.close()` does graceful shutdown (#24184)Divy Srivastava
2024-06-11fix(ext/node): ServerResponse header array handling (#24149)Luca Casonato
Previously res.setHeader("foo", ["bar", "baz"]) added a single header with a value of `bar,baz`. Really this should add two separate headers. This is visible in `set-cookie` for example.
2024-05-28fix(ext/http): flush gzip streaming response (#23991)Bartek Iwańczuk
This commit changes `gzip` compression in `Deno.serve` API to flush data after each write. There's a slight performance regression, but provided test shows a scenario that was not possible before. --------- Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-05-26fix(node): set default http server response code 200 (#23977)Marvin Hagemeister
Node sets the default HTTP response status code to 200 on the `ServerResponse`. We initialised it as `undefined` before which caused a problem with 11ty's dev server. Thanks to @vrugtehagel for reporting this issue and finding the correct fix as well 🎉 Fixes https://github.com/denoland/deno/issues/23970
2024-04-24feat(ext/http): Implement request.signal for Deno.serve (#23425)Matt Mastracci
When the response has been successfully send, we abort the `Request.signal` property to indicate that all resources associated with this transaction may be torn down.
2024-04-21fix(ext/node): define http.maxHeaderSize (#23479)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/23432
2024-04-05fix(ext/node): hostname is valid IPv4 addr (#23243)Divy Srivastava
Fixes `docusaurus serve`
2024-03-10fix(node:http) Export `validateHeaderName` and `validateHeaderValue` ↵mash-graz
functions (#22616) Modify `_http_outgoing.ts` to support the extended signature of `validateHeaderName()` used since node v19.5.0/v18.14.0 by adding the `label` parameter. (see: https://nodejs.org/api/http.html#httpvalidateheadernamename-label) Making both validation functions accessible as public exports of `node:http` Fixes: #22614
2024-02-29fix(ext/node) add node http methods (#22630)Igor Zinkovsky
fixes #22627 This PR fixes a node compat issue that is preventing `serverless-http` and `serverless-express` npm modules from working with Deno. These modules are useful for running apps on AWS Lambda (and other serverless infra). --------- Signed-off-by: Igor Zinkovsky <igor@deno.com>
2024-02-18BREAKING(unstable): remove `Deno.HttpClient.rid` (#22075)Asher Gomez
As part of ongoing works to make `rid` private. --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-01-29refactor: Use virtul ops module (#22175)Bartek Iwańczuk
Follow up to #22157. This leaves us with 4 usages of `ensureFastOps()` in `deno` itself. There's also about 150 usages of `Deno.core.ops.<op_name>` left as well.
2024-01-29refactor: migrate 'ext/node' extension to virtual ops module (#22157)Bartek Iwańczuk
Follow up to https://github.com/denoland/deno/pull/22135
2024-01-23refactor: set removal version for `Deno.Server` (#22024)Asher Gomez
This change sets the removal version for the deprecated `Deno.Server` interface for Deno 2.0. Towards #22021
2024-01-19fix(node/http): remoteAddress and remotePort not being set (#21998)Marvin Hagemeister
<!-- Before submitting a PR, please read https://deno.com/manual/contributing 1. Give the PR a descriptive title. Examples of good title: - fix(std/http): Fix race condition in server - docs(console): Update docstrings - feat(doc): Handle nested reexports Examples of bad title: - fix #7123 - update docs - fix bugs 2. Ensure there is a related issue and it is referenced in the PR text. 3. Ensure there are tests that cover the changes. 4. Ensure `cargo test` passes. 5. Ensure `./tools/format.js` passes without changing files. 6. Ensure `./tools/lint.js` passes. 7. Open as a draft PR if your work is still in progress. The CI won't run all steps, but you can add '[ci]' to a commit message to force it to. 8. If you would like to run the benchmarks on the CI, add the 'ci-bench' label. --> Ultimately, it came down to using incorrect property names in the `FakeSocket` constructor. The values are passed under `remoteAddress`, not `hostname` and `remotePort` instead of `port`. Fixes https://github.com/denoland/deno/issues/21980
2024-01-18chore: upgrade deno_core to 0.247.0 (#21974)Bartek Iwańczuk
2024-01-18fix(node): update `req.socket` on WS upgrade (#21984)Divy Srivastava
Update the `req.socket` to be a `net.Socket` from `FakeSocket` Fixes #21979
2024-01-10refactor: use `core.ensureFastOps()` (#21888)Kenta Moriuchi
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-12-27perf: remove opAsync (#21690)Matt Mastracci
`opAsync` requires a lookup by name on each async call. This is a mechanical translation of all opAsync calls to ensureFastOps. The `opAsync` API on Deno.core will be removed at a later time.
2023-12-25fix(ext/node): add ClientRequest#setNoDelay (#21694)Divy Srivastava
Fixes https://github.com/denoland/deno/issues/18316
2023-12-11fix(ext/node): ServerResponse getHeader() return undefined (#21525)Divy Srivastava
Matches Node's return type. Next.js check for `if (header === undefined)`: https://github.com/vercel/next.js/blob/e02fe314dcd0ae614c65b505c6daafbdeebb920e/packages/next/src/server/base-http/node.ts#L93
2023-12-11fix(ext/node): stub ServerResponse#flushHeaders (#21526)Divy Srivastava
This commit adds a no-op flushHeaders method to the ServerResponse object. It is a nop because the ServerResponse implementation is based on top of the Deno server API instead of the Node `OutgoingMessage` base. Fixes #21509
2023-12-01refactor: use resourceForReadableStream for fetch (#20217)Matt Mastracci
Switch `ext/fetch` over to `resourceForReadableStream` to simplify and unify implementation with `ext/serve`. This allows us to work in Rust with resources only. Two additional changes made to `resourceForReadableStream` were required: - Add an optional length to `resourceForReadableStream` which translates to `size_hint` - Fix a bug where writing to a closed stream that was full would panic
2023-11-22refactor: replace `deferred()` from `std/async` with ↵Asher Gomez
`Promise.withResolvers()` (#21234) Closes #21041 --------- Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-11-11fix(node/http): export globalAgent (#21081)Jacob Hummer
Fixes #21080 Fixes #18312 --------- Signed-off-by: Jacob Hummer <jcbhmr@outlook.com>
2023-11-07fix(node/http): socket.setTimeout (#20930)Gasman
Fixes #20923
2023-08-29fix(node/http): don't leak resources on destroyed request (#20040)Bartek Iwańczuk
Closes https://github.com/denoland/deno/issues/19828