diff --git a/akka-http-core/src/main/scala/akka/http/impl/util/package.scala b/akka-http-core/src/main/scala/akka/http/impl/util/package.scala index c8644d6e18..9def14b3ab 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/util/package.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/util/package.scala @@ -121,6 +121,15 @@ package object util { private[this] val _identityFunc: Any ⇒ Any = x ⇒ x /** Returns a constant identity function to avoid allocating the closure */ private[http] def identityFunc[T]: T ⇒ T = _identityFunc.asInstanceOf[T ⇒ T] + + private[http] def humanReadableByteCount(bytes: Long, si: Boolean): String = { + val unit = if (si) 1000 else 1024 + if (bytes >= unit) { + val exp = (math.log(bytes) / math.log(unit)).toInt + val pre = if (si) "kMGTPE".charAt(exp - 1).toString else "KMGTPE".charAt(exp - 1).toString + 'i' + "%.1f %sB" format (bytes / math.pow(unit, exp), pre) + } else bytes.toString + " B" + } } package util { diff --git a/akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/marshallers/sprayjson/SprayJsonSupport.scala b/akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/scaladsl/marshallers/sprayjson/SprayJsonSupport.scala similarity index 85% rename from akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/marshallers/sprayjson/SprayJsonSupport.scala rename to akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/scaladsl/marshallers/sprayjson/SprayJsonSupport.scala index 1262a0bcff..aa53ca4349 100644 --- a/akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/marshallers/sprayjson/SprayJsonSupport.scala +++ b/akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/scaladsl/marshallers/sprayjson/SprayJsonSupport.scala @@ -2,15 +2,15 @@ * Copyright (C) 2009-2014 Typesafe Inc. */ -package akka.http.marshallers.sprayjson +package akka.http.scaladsl.marshallers.sprayjson import scala.language.implicitConversions import scala.concurrent.ExecutionContext import akka.stream.FlowMaterializer -import akka.http.marshalling.{ ToEntityMarshaller, Marshaller } -import akka.http.unmarshalling.{ FromEntityUnmarshaller, Unmarshaller } -import akka.http.model.{ ContentTypes, HttpCharsets } -import akka.http.model.MediaTypes.`application/json` +import akka.http.scaladsl.marshalling.{ ToEntityMarshaller, Marshaller } +import akka.http.scaladsl.unmarshalling.{ FromEntityUnmarshaller, Unmarshaller } +import akka.http.scaladsl.model.{ ContentTypes, HttpCharsets } +import akka.http.scaladsl.model.MediaTypes.`application/json` import spray.json._ /** diff --git a/akka-http-marshallers-scala/akka-http-xml/src/main/scala/akka/http/marshallers/xml/ScalaXmlSupport.scala b/akka-http-marshallers-scala/akka-http-xml/src/main/scala/akka/http/scaladsl/marshallers/xml/ScalaXmlSupport.scala similarity index 92% rename from akka-http-marshallers-scala/akka-http-xml/src/main/scala/akka/http/marshallers/xml/ScalaXmlSupport.scala rename to akka-http-marshallers-scala/akka-http-xml/src/main/scala/akka/http/scaladsl/marshallers/xml/ScalaXmlSupport.scala index 3cce70ae83..fd03c08135 100644 --- a/akka-http-marshallers-scala/akka-http-xml/src/main/scala/akka/http/marshallers/xml/ScalaXmlSupport.scala +++ b/akka-http-marshallers-scala/akka-http-xml/src/main/scala/akka/http/scaladsl/marshallers/xml/ScalaXmlSupport.scala @@ -2,16 +2,16 @@ * Copyright (C) 2009-2014 Typesafe Inc. */ -package akka.http.marshallers.xml +package akka.http.scaladsl.marshallers.xml import java.io.{ ByteArrayInputStream, InputStreamReader } import scala.collection.immutable import scala.concurrent.ExecutionContext import scala.xml.{ XML, NodeSeq } import akka.stream.FlowMaterializer -import akka.http.unmarshalling._ -import akka.http.marshalling._ -import akka.http.model._ +import akka.http.scaladsl.unmarshalling._ +import akka.http.scaladsl.marshalling._ +import akka.http.scaladsl.model._ import MediaTypes._ trait ScalaXmlSupport {