Re: [whatwg/fetch] Request body streams should use chunked encoding (#966)

I am the engineer behind Ruby's [`async-http`](https://github.com/socketry/async-http) HTTP/1.x and HTTP/2 client & server and [`falcon`](https://github.com/socketry/falcon) which is a zero-configuration HTTP/1 & HTTP/2 server for Ruby web applications.

When I first started working on `async-http` it was not clear to me that bi-directional streaming was possible via HTTP/1. But there are two ways it can work, one is standards compliant and one is possibly in violation of the standards.

a/ For HTTP/1.0 (and 1.1) you can leverage `shutdown(WR)` and use a request body without a content-length (and obviously `connection: close`). This is in violation of the spec but only slightly and in practice it does work in certain situations. We don't expose this by default since it violates the spec, but at least I wanted to comment on it since I played around with it and it allows bi-directional streaming without chunked encoding.

b/ For HTTP/1.1, using chunked encoding for the request body works perfectly and is completely standards compliant.

c/ For HTTP/2, obviously this is a non-issue.

Falcon supports (b) and (c) by default, out of the box.

I wanted to try this out and provide a way for others to try it out too, so I quickly threw together a remote echo server.

Firstly, you can get the client and server here: https://github.com/socketry/utopia-falcon-heroku/

The application is hosted on Heroku right now: https://utopia-falcon-heroku.herokuapp.com/

## Response Streaming

http://utopia-falcon-heroku.herokuapp.com/beer/index?count=100

It is actually going via an HTTP/1.1 middle box and working perfectly.

## Request Streaming

### Locally (working)

Using the code above:

```
$ bundle install
$ falcon serve
```

To start the client:

```
$ rake echo URL=https://localhost:9292/echo/index
```

Type some lines and they will be echoed back in real time.

### Heroku (not working?)

Run this on the client:

```
$ rake echo URL=https://utopia-falcon-heroku.herokuapp.com/echo/index
```

You should be able to type lines and get an interactive response, but it seems like the request might be getting buffered. I can add more logging on the server to see what is going on, and will report back.

## Conclusion

I wish that we would focus on the standards more than the existing implementations. The point of the standard is to say how it should work. And the point of the engineer is to implement it. The standard can say "This should work on HTTP/1.1" and it's within the existing design parameters. The fact it doesn't work is a bug. By encoding this into the standard, you are essentially encoding buggy designs into the standard. If you do this repeatedly, I can imagine that we end up with a huge mess based on crappy implementations, and standards that are getting repeatedly more messy.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/966#issuecomment-555824349

Received on Wednesday, 20 November 2019 03:46:18 UTC