cloudflare / cloudflare/workers-rs

[BUG] New http return types always use chunked transfer encoding

Open
#511 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.7k
Forks
429
Avg merge
20h 28m
Merged PRs (30d)
7

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### What version of `workers-rs` are you using?

0.0.23

### What version of `wrangler` are you using?

3.39.0

### Describe the bug

After experimenting with the new http feature, I noticed that `transfer-encoding: chunked` is returned for all responses, even when manually specifying a `content-length` header. I'm not sure this is a problem for everyone but it's a change from earlier releases.

### Steps To Reproduce

Prior release returning `Content-Length: 2`:
```rust
#[event(fetch)]
async fn fetch(_req: Request, _env: Env, _ctx: Context) -> Result {
let mut headers = Headers::new();
let _ = headers.set("content-type", "application/json");
let response = worker::Response::from_bytes("{}".into())
.unwrap()
.with_headers(headers);
Ok(response)
}
```
```shell
HTTP/1.1 200 OK
Content-Length: 2
Content-Type: application/json
```

0.0.23 release returning `Transfer-Encoding: chunked`:
```rust
#[event(fetch)]
async fn fetch(req: HttpRequest, _env: Env, _ctx: Context) -> Result> {
Ok(http::Response::builder()
.header("content-type", "application/json")
.header("content-length", "2")
.body("{}".into())
.unwrap())
}
```
```shell
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/json
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.