ceylon-sdk
ceylon-sdk copied to clipboard
ceylon.net.http.server.Request should allow to access the raw bytes
Current state In a HTTP server implementation (using the ceylon.net.http.server package), currently the body of a POST or PUT request can only be accessed in String form.
(For multipart/form-data requests, one can also access the uploaded files, assuming one knows the (form item?) names. There is no way to list all.)
I suppose the server will use the request's Content-Type header to figure out how it is encoded, with some fallback.
While this is okay for cases when text entities are sent (with an encoding marked), it doesn't allow to process binary data (like a PDF upload), nor does it allow streaming big requests which might not fit into the server's memory.
Proposal It should be possible to access the data in
- [x] ~~a "raw way" (bytes, not strings)~~ (done)
- [ ] a "streaming way" (read however much already arrived).
It looks like ceylon.io.readers.Reader is the correct interface here (which is analogous to a java.io.InputStream). ceylon.io is already a shared dependency of ceylon.net.
Something similar was implemented in #489 (providing a shared Byte[] readBinary().)
@dlkw so does that mean you think this issue could be closed? Or is it still interesting because we don't have point 2 yet, the "streaming way"?
I didn't need to process large bodies in binary yet, but I think a streaming way will be useful and a Byte[] will be awkward sometimes.
Ok, let's leave this issue open then especially for that purpose (I changed the description a bit to show that)
What is the state of this issue? Is anyone working on it?
Not sure but I don't think so right now.