summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
AgeCommit message (Collapse)Author
2024-02-10chore: move cli/tests/ -> tests/ (#22369)Matt Mastracci
This looks like a massive PR, but it's only a move from cli/tests -> tests, and updates of relative paths for files. This is the first step towards aggregate all of the integration test files under tests/, which will lead to a set of integration tests that can run without the CLI binary being built. While we could leave these tests under `cli`, it would require us to keep a more complex directory structure for the various test runners. In addition, we have a lot of complexity to ignore various test files in the `cli` project itself (cargo publish exclusion rules, autotests = false, etc). And finally, the `tests/` folder will eventually house the `test_ffi`, `test_napi` and other testing code, reducing the size of the root repo directory. For easier review, the extremely large and noisy "move" is in the first commit (with no changes -- just a move), while the remainder of the changes to actual files is in the second commit.
2024-02-07chore(cli): Use @test_util for relative path for unit tests (#22327)Matt Mastracci
This removes the majority of `../../../../../../test_util` relative imports from the codebase, allowing us to move this code more easily in the future.
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-12-31fix(http_client): Fix Deno.createHttpClient to accept poolIdleTimeout ↵Raashid Anwar
parameter (#21603) Fixed the bug `Deno.createHttpClient` to accept `poolIdleTimeout` parameter. Fixes https://github.com/denoland/deno/issues/21546
2023-12-06feat(ext/fetch): allow `Deno.HttpClient` to be declared with `using` (#21453)Yusuke Tanaka
This commit adds a method of `Symbol.dispose` to the object returned from `Deno.createHttpClient`, so we can make use of [explicit resource management](https://github.com/tc39/proposal-explicit-resource-management) by declaring it with `using`.
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-10chore(cli): Migrate some unit tests to "Promise.withResolvers()" (#21128)Tareque Md Hanif
Migrate to use `Promise.withResolvers()` instead of `deferred` in some of the tests in `cli/tests/unit/`. Issue: #21041
2023-09-26fix(cli/test): clear connection pool after tests (#20680)Luca Casonato
This helps reduce flakes where a test starts an HTTP server and makes a request using fetch, then shuts down the server, then starting a new test with a new server, but the connection pool still has a "not quite closed yet" connection to the old server, and a new request to the new server gets sent on the closed connection, which obviously errors out.
2023-09-16perf: improve async op santizer speed and accuracy (#20501)Luca Casonato
This commit improves async op sanitizer speed by only delaying metrics collection if there are pending ops. This results in a speedup of around 30% for small CPU bound unit tests. It performs this check and possible delay on every collection now, fixing an issue with parent test leaks into steps.
2023-08-16fix: release ReadeableStream in fetch (#17365)Leo Kettmeir
Fixes #16648 --------- Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-07-31chore(cli): Reduce port conflict in tests (#19988)Matt Mastracci
Ports are still occasionally causing CI flake -- allocate and separate ports further for fetch/http tests.
2023-07-28feat: Deno.createHttpClient allowHost (#19689)Leo Kettmeir
This adds an option to allow using the host header in a fetch call. Closes https://github.com/denoland/deno/issues/16840 Ref https://github.com/denoland/deno/issues/11017
2023-06-26chore: fix typos (#19572)Martin Fischer
2023-05-22chore(cli): One Rust test per JS and Node unit test file (#19199)Matt Mastracci
This runs our `js_unit_tests` and `node_unit_tests` in parallel, one rust test per JS unit test file. Some of our JS tests don't like running in parallel due to port requirements, so this also makes those use a specific port-per-file. This does not attempt to make the node-compat tests work.
2023-05-21fix(ci): simplify test assertion for http version enforcing with ↵Leo Kettmeir
Deno.createHttpClient (#19210)
2023-05-21feat(unstable): add more options to Deno.createHttpClient (#17385)Leo Kettmeir
2023-05-17fix: support "fetch" over HTTPS for IP addresses (#18499)Bartek Iwańczuk
This commit adds support for connecting to IP addresses over HTTPS. This is done by updating "rustls" to "0.21.0" and other related crates. Closes https://github.com/denoland/deno/issues/7660 Closes https://github.com/denoland/deno/issues/17967 --------- Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-28fix(ext/fetch): subview Uint8Array in Req/Resp (#18890)Luca Casonato
2023-03-22test: ignore fetchWithInvalidContentLength and fetchConnectionError on ↵Bartek Iwańczuk
Windows (#18351) https://github.com/denoland/deno/issues/18350
2023-03-22test: mark two unit tests as flaky (#18344)Bartek Iwańczuk
Temporarily marking two "fetch" tests as flaky, since they've been failing on CI for the past 24h.
2023-01-02chore: update copyright year to 2023 (#17247)David Sherret
Yearly tradition of creating extra noise in git.
2022-12-23fix(ext/fetch): Guard against invalid URL before its used by reqwest (#17164)Kamil Ogórek
2022-12-19test(ext/fetch): fix test in release mode (#17125)Luca Casonato
2022-12-19fix(ext/fetch): handle errors in req body stream (#17081)Luca Casonato
Right now an error in a request body stream causes an uncatchable global promise rejection. This PR fixes this to instead propagate the error correctly into the promise returned from `fetch`. It additionally fixes errored readable stream bodies being treated as successfully completed bodies by Rust.
2022-12-06fix(ext/fetch): new Request should soft clone (#16869)Luca Casonato
Previously the inner request object of the original and the new request were the same, causing the requests to be entangled and mutable changes to one to be visible to the other. This fixes that.
2022-10-09feat(core): improve resource read & write traits (#16115)Luca Casonato
This commit introduces two new buffer wrapper types to `deno_core`. The main benefit of these new wrappers is that they can wrap a number of different underlying buffer types. This allows for a more flexible read and write API on resources that will require less copying of data between different buffer representations. - `BufView` is a read-only view onto a buffer. It can be backed by `ZeroCopyBuf`, `Vec<u8>`, and `bytes::Bytes`. - `BufViewMut` is a read-write view onto a buffer. It can be cheaply converted into a `BufView`. It can be backed by `ZeroCopyBuf` or `Vec<u8>`. Both new buffer views have a cursor. This means that the start point of the view can be constrained to write / read from just a slice of the view. Only the start point of the slice can be adjusted. The end point is fixed. To adjust the end point, the underlying buffer needs to be truncated. Readable resources have been changed to better cater to resources that do not support BYOB reads. The basic `read` method now returns a `BufView` instead of taking a `ZeroCopyBuf` to fill. This allows the operation to return buffers that the resource has already allocated, instead of forcing the caller to allocate the buffer. BYOB reads are still very useful for resources that support them, so a new `read_byob` method has been added that takes a `BufViewMut` to fill. `op_read` attempts to use `read_byob` if the resource supports it, which falls back to `read` and performs an additional copy if it does not. For Rust->JS reads this change should have no impact, but for Rust->Rust reads, this allows the caller to avoid an additional copy in many scenarios. This combined with the support for `BufView` to be backed by `bytes::Bytes` allows us to avoid one data copy when piping from a `fetch` response into an `ext/http` response. Writable resources have been changed to take a `BufView` instead of a `ZeroCopyBuf` as an argument. This allows for less copying of data in certain scenarios, as described above. Additionally a new `Resource::write_all` method has been added that takes a `BufView` and continually attempts to write the resource until the entire buffer has been written. Certain resources like files can override this method to provide a more efficient `write_all` implementation.
2022-10-04perf(ext/fetch): consume body using ops (#16038)Marcos Casagrande
This commit adds a fast path to `Request` and `Response` that make consuming request bodies much faster when using `Body#text`, `Body#arrayBuffer`, and `Body#blob`, if the body is a FastStream. Because the response bodies for `fetch` are FastStream, this speeds up consuming `fetch` response bodies significantly.
2022-09-28feat: implement Web Cache API (#15829)Satya Rohith
2022-09-27fix(ext/fetch): blob url (#16057)Satya Rohith
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-09-26perf(ext/fetch): use content-length in InnerBody.consume (#15925)Marcos Casagrande
This fast path prevents repeated allocations when receiving a fetch body with a known size. Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-09-23test(ext/fetch): enable null body status test on windows (#15995)Marcos Casagrande
2022-09-19refactor: move out test files from root testdata directory into sub ↵David Sherret
directories (#15949)
2022-09-06perf(runtime): short-circuit `queue_async_op` for Poll::Ready (#15773)Divy Srivastava
2022-08-23fix(ext/fetch): ignore user content-length header (#15555)Luca Casonato
Previously if a user specified a content-length header for an POST request without a body, the request would contain two `content-length` headers. One added by us, and one added by the user. This commit ignores all content-length headers coming from the user, because we need to have the sole authority on the content-length because we transmit the body.
2022-07-20chore: use import.meta.resolve() in tests (#15256)Bartek Iwańczuk
2022-07-20chore: align some Web API type definitions to lib.dom.d.ts (#15219)ayame113
2022-06-19fix(ext/fetch): add `accept-language` default header to fetch (#14882)Mark Ladyshau
2022-05-18fix: add types for `Response.json` (#14655)Luca Casonato
2022-03-16feat(ext/fetch): Allow Response status 101 (#13969)Ryan Dahl
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-02-16tests: deflake a bunch of net related tests (#13685)Luca Casonato
2022-01-20chore: update copyright year (#13434)Yoshiya Hinosawa
2021-12-16feat(fetch): support abort reasons in fetch (#13106)Andreu Botella
2021-11-23refactor: remove "unitTest" wrapper from cli/tests/unit (#12750)Bartek Iwańczuk
2021-11-09fix(fetch): set content-length for empty POST/PUT (#12703)Luca Casonato
This commit changes `fetch` to set `content-length: 0` on POST and PUT requests with no body.
2021-11-01feat(ext/fetch): support fetching local files (#12545)Kitson Kelly
Closes #11925 Closes #2150 Co-authored-by: Bert Belder <bertbelder@gmail.com>
2021-10-25fix(tls): Make TLS clients support HTTP/2 (#12530)Andreu Botella
`fetch()` and client-side websocket used to support HTTP/2, but this regressed in #11491. This patch reenables it by explicitly adding `h2` and `http/1.1` to the list of ALPN protocols on the HTTP and websocket clients.
2021-09-30feat(tls): custom in memory CA certificates (#12219)Luca Casonato
This adds support for using in memory CA certificates for `Deno.startTLS`, `Deno.connectTLS` and `Deno.createHttpClient`. `certFile` is deprecated in `startTls` and `connectTls`, and removed from `Deno.createHttpClient`.
2021-09-29fix(ext/fetch): avoid panic when header is invalid (#12244)Ahab
2021-09-23test(cli): align unit test permissions with runtime test permissions (#12189)Casper Beyer
2021-09-22chore: replace calls to assertThrowsAsync with assertRejects (#12176)Casper Beyer