denoland / denoland/deploy_feedback

Body is always (partially) consumed or buffered, causing requests that should not consume the body to fail

Open
#79 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
79
Forks
5
PR merge metrics
No merged PRs in 30d

Description

No sure if this is a bug in the Deploy proxy or router implementation or a upstream bug for the server library used.
It can be verified very easily. The following snippet just redirects every request:

```typescript
addEventListener("fetch", (event: FetchEvent) => {
return event.respondWith(
Response.redirect("https://pie.dev/status/400", 302)
);
});
```

Testing this using http/2 curl will fail, because the body is starting to get consumed before the 302 is send:

```shell
$ curl -L -v -T test.bin https://free-goose-34.deno.dev/
> PUT /test.bin HTTP/2
> Host: free-goose-34.deno.dev
> user-agent: curl/7.68.0
> accept: */*
> content-length: 268435456
>
< HTTP/2 302
< location: https://pie.dev/status/400
< content-length: 0
< date: Sat, 14 Aug 2021 19:16:39 GMT
< x-deno-ray: europe-west3-c::6447adfc7b0ae52926f37543db0df3b6
* HTTP error before end of send, stop sending
* HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
```

By forcing http/1.1 its actually more obvious what happens:

```shell
$ curl -L -v -T test.bin https://free-goose-34.deno.dev/ --http1.1
> PUT /test.bin HTTP/1.1
> Host: free-goose-34.deno.dev
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 268435456
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 302 Found
< location: https://pie.dev/status/400
< date: Sat, 14 Aug 2021 19:18:24 GMT
< x-deno-ray: europe-west3-c::385f9bc284563eb59ebb06e11e47f8a6
< content-length: 0
```
Here the `HTTP/1.1 100 Continue` makes it obvious that the body is being read.

The `deno run` server actually handles this correctly:
```shell
$ curl -L -v -T test.bin localhost:8080/upload
> PUT /upload HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 268435456
> Expect: 100-continue
>
< HTTP/1.1 302 Found
< location: https://pie.dev/status/400
< content-length: 0
< date: Sat, 14 Aug 2021 19:09:47 GMT
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.