!htp use immutable collections in Rejections

This commit is contained in:
Johannes Rudolph 2015-08-26 14:36:33 +02:00
parent a70e37d65c
commit 96ef8875c8
3 changed files with 7 additions and 7 deletions

View file

@ -78,13 +78,13 @@ class RangeDirectivesSpec extends RoutingSpec with Inspectors with Inside {
"reject an unsatisfiable single range" in {
Get() ~> addHeader(Range(ByteRange(100, 200))) ~> completeWithRangedBytes(10) ~> check {
rejection shouldEqual UnsatisfiableRangeRejection(Seq(ByteRange(100, 200)), 10)
rejection shouldEqual UnsatisfiableRangeRejection(ByteRange(100, 200) :: Nil, 10)
}
}
"reject an unsatisfiable single suffix range with length 0" in {
Get() ~> addHeader(Range(ByteRange.suffix(0))) ~> completeWithRangedBytes(42) ~> check {
rejection shouldEqual UnsatisfiableRangeRejection(Seq(ByteRange.suffix(0)), 42)
rejection shouldEqual UnsatisfiableRangeRejection(ByteRange.suffix(0) :: Nil, 42)
}
}

View file

@ -70,7 +70,7 @@ case class MalformedHeaderRejection(headerName: String, errorMsg: String,
* Rejection created by unmarshallers.
* Signals that the request was rejected because the requests content-type is unsupported.
*/
case class UnsupportedRequestContentTypeRejection(supported: Set[ContentTypeRange]) extends Rejection
case class UnsupportedRequestContentTypeRejection(supported: immutable.Set[ContentTypeRange]) extends Rejection
/**
* Rejection created by decoding filters.
@ -83,7 +83,7 @@ case class UnsupportedRequestEncodingRejection(supported: HttpEncoding) extends
* Signals that the request was rejected because the requests contains only unsatisfiable ByteRanges.
* The actualEntityLength gives the client a hint to create satisfiable ByteRanges.
*/
case class UnsatisfiableRangeRejection(unsatisfiableRanges: Seq[ByteRange], actualEntityLength: Long) extends Rejection
case class UnsatisfiableRangeRejection(unsatisfiableRanges: immutable.Seq[ByteRange], actualEntityLength: Long) extends Rejection
/**
* Rejection created by range directives.
@ -112,14 +112,14 @@ case object RequestEntityExpectedRejection extends Rejection
* Signals that the request was rejected because the service is not capable of producing a response entity whose
* content type is accepted by the client
*/
case class UnacceptedResponseContentTypeRejection(supported: Set[ContentType]) extends Rejection
case class UnacceptedResponseContentTypeRejection(supported: immutable.Set[ContentType]) extends Rejection
/**
* Rejection created by encoding filters.
* Signals that the request was rejected because the service is not capable of producing a response entity whose
* content encoding is accepted by the client
*/
case class UnacceptedResponseEncodingRejection(supported: Set[HttpEncoding]) extends Rejection
case class UnacceptedResponseEncodingRejection(supported: immutable.Set[HttpEncoding]) extends Rejection
object UnacceptedResponseEncodingRejection {
def apply(supported: HttpEncoding): UnacceptedResponseEncodingRejection = UnacceptedResponseEncodingRejection(Set(supported))
}

View file

@ -97,7 +97,7 @@ trait RangeDirectives {
case _ None
}
def applyRanges(ranges: Seq[ByteRange]): Directive0 =
def applyRanges(ranges: immutable.Seq[ByteRange]): Directive0 =
extractRequestContext.flatMap { ctx
mapRouteResultWithPF {
case Complete(HttpResponse(OK, headers, entity, protocol))