!hco #15915 introduce more shades of HttpEntities

The introduction of BodyParts again showed that not all entity types are
useful for every kind of context. There are now these contexts where
HttpEntities are used:
 - requests
 - responses
 - body parts

And several kinds of entities:
 - Strict
 - Default
 - Chunked
 - CloseDelimited
 - IndefiniteLength

To increase type safety of the API marker-interfaces are introduced defining
which kinds of entities can be used in which contexts:
 - RequestEntity: Strict, Default, Chunked
 - ResponseEntity: Strict, Default, Chunked, CloseDelimited
 - BodyPartEntity: Strict, Default, IndefiniteLength

Also, to be able still to provide abstractions over some kinds of entities
additional auxiliary interfaces were necessary:
 - MessageEntity = RequestEntity >: ResponseEntity: Strict, Default, Chunked (type alias for RequestEntity)
 - UniversalEntity = RequestEntity with ResponseEntity with BodyPartEntity = Strict, Default
This commit is contained in:
Johannes Rudolph 2014-09-22 11:56:10 +02:00
parent 1e6a844dc1
commit c77f4e28f6
40 changed files with 289 additions and 159 deletions

View file

@ -39,7 +39,7 @@ trait RouteTestResultComponent {
def response: HttpResponse = rawResponse.copy(entity = entity)
/** Returns a "fresh" entity with a "fresh" unconsumed byte- or chunk stream (if not strict) */
def entity: HttpEntity = entityRecreator()
def entity: ResponseEntity = entityRecreator()
def chunks: immutable.Seq[ChunkStreamPart] =
entity match {
@ -76,7 +76,7 @@ trait RouteTestResultComponent {
this
}
private[this] lazy val entityRecreator: () HttpEntity =
private[this] lazy val entityRecreator: () ResponseEntity =
rawResponse.entity match {
case s: HttpEntity.Strict () s