ceylon-sdk icon indicating copy to clipboard operation
ceylon-sdk copied to clipboard

ceylon.net.http.server.Request should allow to access the raw bytes

Open ePaul opened this issue 9 years ago • 6 comments

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.

ePaul avatar Dec 21 '15 20:12 ePaul

Something similar was implemented in #489 (providing a shared Byte[] readBinary().)

dlkw avatar Feb 24 '16 21:02 dlkw

@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"?

quintesse avatar Feb 24 '16 22:02 quintesse

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.

dlkw avatar Feb 25 '16 21:02 dlkw

Ok, let's leave this issue open then especially for that purpose (I changed the description a bit to show that)

quintesse avatar Feb 25 '16 21:02 quintesse

What is the state of this issue? Is anyone working on it?

luolong avatar Oct 03 '16 10:10 luolong

Not sure but I don't think so right now.

quintesse avatar Oct 03 '16 10:10 quintesse