diff --git a/s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala b/s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala index 72b32beb5c..332d419ed9 100644 --- a/s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala +++ b/s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala @@ -65,10 +65,12 @@ private[alpakka] final class S3Stream(credentials: AWSCredentials, Source.fromFuture(request(s3Location, range).flatMap(entityForSuccess).map(_.dataBytes)).flatMapConcat(identity) } - def request(s3Location: S3Location, range: Option[ByteRange] = None): Future[HttpResponse] = { + def request(s3Location: S3Location, rangeOption: Option[ByteRange] = None): Future[HttpResponse] = { val downloadRequest = getDownloadRequest(s3Location, region) - val rangeHeader = range.map(headers.Range(_)) - signAndGet(rangeHeader.map(downloadRequest.withHeaders(_)).getOrElse(downloadRequest)) + signAndGet(rangeOption match { + case Some(range) => downloadRequest.withHeaders(headers.Range(range)) + case _ => downloadRequest + }) } /**