summaryrefslogtreecommitdiff
path: root/ext/http/lib.rs
AgeCommit message (Collapse)Author
2022-12-20fix(ext/http): close stream on resp body error (#17126)Luca Casonato
Previously, errored streaming response bodies did not cause the HTTP stream to be aborted. It instead caused the stream to be closed gracefully, which had the result that the client could not detect the difference between a successful response and an errored response. This commit fixes the issue by aborting the stream on error.
2022-11-04fix(ext/http): flush chunk when streaming resource (#16536)Luca Casonato
When streaming a resource in ext/http, with compression enabled, we didn't flush individual chunks. This became very problematic when we enabled `req.body` from `fetch` for FastStream recently. This commit now correctly flushes each resource chunk after compression.
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-30refactor(ext/http): remove op_http_read (#16096)Luca Casonato
We can use Resource::read_return & op_read instead. This allows HTTP request bodies to participate in FastStream. To make this work, `readableStreamForRid` required a change to allow non auto-closing resources to be handled. This required some minor changes in our FastStream paths in ext/http and ext/flash.
2022-08-18feat(ext/flash): An optimized http/1.1 server (#15405)Divy Srivastava
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl> Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2022-07-12fix(ext/http): reading headers with ongoing body reader (#15161)Divy Srivastava
2022-07-04perf(ext/http): remove accept_encoding interior mutability (#15070)Divy Srivastava
2022-07-04perf(ext/http): simplify op_http_accept (#15067)Divy Srivastava
2022-07-04perf(ext/http): lazy load headers (#15055)Divy Srivastava
2022-05-18perf(ext/http): faster accept-encoding parsing (#14654)Aaron O'Mullan
2022-05-17fix(ext/http): error on invalid headers (#14642)Aaron O'Mullan
Minor regression/change-in-behaviour from #14552 that filtered out invalid http headers in rust vs error-ing back to JS
2022-05-17fix(ext/http): skip auto-compression if content-encoding present (#14641)Aaron O'Mullan
Regression from #14552
2022-05-13fix(ext/http): make serveHttp compress for Accept-Encoding: deflate, gzip ↵Andy Kurnia
(#14525)
2022-05-13feat(serde_v8): bytes::Bytes support (#14412)Aaron O'Mullan
2022-05-10cleanup(ext/http): simpler http write ops (#14552)Aaron O'Mullan
Facilitates making `op_http_write_headers` sync and thus faster
2022-04-25fix(ext/http): truncate read bytes when streaming bodies (#14389)Divy Srivastava
stream shutdown wasn't happening correctly (moved it to call op_http_shutdown) & extra zeroed bytes were being sent for when body length not a multiple of 64*1024
2022-04-25perf(ext/http): fast path for uncompressed bodies (#14366)Divy Srivastava
2022-04-24perf(ext/http): faster is_content_compressible (#14383)Aaron O'Mullan
Cleanup + benches
2022-04-24perf(serde_v8): zero-copy StringOrBuffer (#14381)Aaron O'Mullan
2022-04-22Reland "perf(http): optimize ReadableStreams backed by a resource" (#14346)Divy Srivastava
2022-04-21Reland "feat(ext/http): stream auto resp body compression" (#14345)Divy Srivastava
2022-04-21Revert various PRs related to "ext/http" (#14339)Bartek Iwańczuk
* Revert "feat(ext/http): stream auto resp body compression (#14325)" * Revert "core: introduce `resource.read_return` (#14331)" * Revert "perf(http): optimize `ReadableStream`s backed by a resource (#14284)"
2022-04-20feat(ext/http): stream auto resp body compression (#14325)Luca Casonato
This commit adds support for auto response body compression for streaming bodies.
2022-04-20core: introduce `resource.read_return` (#14331)Divy Srivastava
2022-04-20perf(http): optimize `ReadableStream`s backed by a resource (#14284)Divy Srivastava
2022-04-04chore(ext/http): custom arity (#14200)Divy Srivastava
2022-04-02experiment(serde_v8): derive_more enabled opaque wrappers (#14096)Aaron O'Mullan
2022-03-21perf(http): avoid per header alloc (#14051)Aaron O'Mullan
2022-03-16feat(unstable): Add Deno.upgradeHttp API (#13618)Bert Belder
This commit adds "Deno.upgradeHttp" API, which allows to "hijack" connection and switch protocols, to eg. implement WebSocket required for Node compat. Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Ryan Dahl <ry@tinyclouds.org> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-03-16feat(ops): optional OpState (#13954)Aaron O'Mullan
2022-03-14feat(ops): custom arity (#13949)Aaron O'Mullan
Also cleanup & drop ignored wildcard op-args
2022-03-14feat(core): codegen ops (#13861)Divy Srivastava
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-03-07fix(ext/http): drop content-length header on compression (#13866)Satya Rohith
2022-03-04feat(ext/http): auto-compression of fixed response bodies (#13769)Kitson Kelly
Co-authored-by: Ryan Dahl <ry@tinyclouds.org> Co-authored-by: Satya Rohith <me@satyarohith.com> Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
2022-02-16feat: deno vendor (#13670)David Sherret
2022-02-16feat(ext/http): add support for unix domain sockets (#13628)ylxdzsw
2022-01-07chore: update copyright to 2022 (#13306)Ryan Dahl
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2021-11-10refactor(ext/http): rewrite hyper integration and fix bug (#12732)Bert Belder
Fixes: #12193 Fixes: #12251 Closes: #12714
2021-11-09Revert "refactor(ext/http): rewrite hyper integration and fix bug (#12332)" ↵Luca Casonato
(#12704) This reverts commit 5b1e537446454f6332de44adbeb6a15ff072c2fa.
2021-11-08refactor(ext/http): rewrite hyper integration and fix bug (#12332)Bert Belder
Fixes: #12193
2021-10-26fix(ext/http): allow multiple values in upgrade header for websocket (#12551)Leo K
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2021-10-26perf(http): encode string bodies in op-layer (#12451)Aaron O'Mullan
Using serde_v8's StringOrBuffer
2021-10-17docs(ext/http): fix typo in http/lib.rs (#12466)Ikko Ashimine
2021-10-11fix(http): don't expose body on GET/HEAD requests (#12260)Luca Casonato
GET/HEAD requests can't have bodies according to `fetch` spec. This commit changes the HTTP server to hide request bodies for requests with GET or HEAD methods.
2021-10-05chore: various op cleanup (#12329)Leo K
2021-09-26fix(ext/http): include port number in h2 urls (#12181)Ben Noordhuis
2021-09-25fix(http): panic when responding to a closed conn (#12216)Aaron O'Mullan
Our oneshot receiver in `HyperService::call` would unwrap and panic, the `.await` on the oneshot receiver happens when the sender is dropped. The sender is dropped in `op_http_response` because: 1. We take `ResponseSenderResource` 2. Then get `ConnResource` and early exit on failure (conn already closed) 3. The taken sender then gets dropped in this early exit before any response is sent over the channel Fallbacking to returning a dummy response to hyper seems to be a fine quickfix
2021-09-25fix(ext/http): fortify "is websocket?" check (#12179)Ben Noordhuis
Check for expected headers more rigorously and check that it's a HTTP/1.1 GET request. The logic mirrors what Deno Deploy and the tungstenite crate do. The presence of "Sec-Websocket-Version: 13" is now also enforced. I don't expect that to break anything: conforming clients already send it and tungstenite can't talk to older clients anyway. The new code is more efficient due to heap-allocating less and aligns more closely with the checks in ext/http/01_http.js now.
2021-08-31fix: move unstable declarations to deno.unstable (#11876)Luca Casonato