Support non-UTF8 requests
The String instance of readBody in the Node server assumes UTF8, it should check Content-Type header.
It should also support binary data, and streaming, and MIME in general. I think the fundep on ReadableBody needs to be removed for this.
@rightfold Agreed. Not sure where you mean the functional dependency is, though?
Fundep from body reader type to body type.
class ReadableBody req m b | req -> b
Yes, you're absolutely right. I'll try loosening that, and adding some more instances.
Regarding binary, I could add an instance for getting an Aff e Buffer, as with String.
For streaming, exposing the request's Stream will do for now. In the spirit of Hyper, the stream should only be allowed to be read once (it cannot be read twice, but you could get a compile-time error if you try). That would probably require some other design than just handing back the Readable stream -- like hiding the streaming within the indexed monad and track whether you've been streaming or not. Any thoughts?
Well, where "read once" means "read until exhausted." Stream has a godforsaken Node.js-style callback API, so you can't really demand to read it twice, right? It'll just stop calling you when there's nothing to read.
Regarding this issue, it should only be about the String instance checking the Content-Type header and using that when doing toString on the buffer. Buffers in general, and streaming, are separate issues, but we already have the PRs open. :+1: