Closed sirthias closed 11 years ago
What would case CompoundHttpData(head: NonEmptyHttpData, tail: HttpData) extends NonEmptyHttpData be used for?
It would allow you mix content that you application provides in-memory with content coming from files. This might be useful, for example, for producing multipart message entities.
Would this be based on http://tools.ietf.org/html/rfc2387 ?
We already have support for (un)marshalling multipart messages. Check out this thread for more background on this ticket: https://groups.google.com/forum/#!searchin/spray-user/wall/spray-user/oS0GNXHSMJU/uIFDFkq42moJ
Currently the
HttpEntity
is modeled to be either anEmptyEntity
or anHttpBody
:whereby the
buffer
of anHttpBody
is guaranteed to be non-empty.Proposal: change the
HttpBody
to this:whereby the
data
are modeled like this:We should have convenience constructors (
HttpData.apply
) for easily wrapping aByteString
orFile
, which provide the emptyness check and return eitherEmptyHttpData
or anNonEmptyHttpData
incarnation.The
MessageChunk
can then also be changed from this:to this
This allow us to make use of the new
WriteFile
command available with the new Akka IO layer and have the spray-can layer send file content without the need for loading it into the JVM heap first.Additionally we could use it on the incoming side as well and have spray-can dump incoming data right into a file and deliver the message data as a
HttpFileBytes
instance (size threshold and file system location would be configurable).