All Downloads are FREE. Search and download functionalities are using the official Maven repository.

as.core.scala Maven / Gradle / Ivy

There is a newer version: 0.13.4
Show newest version
package dispatch.as

import dispatch._

import com.ning.http.client
import java.nio.charset.Charset

object Response {
  def apply[T](f: client.Response => T) = f
}

object String extends (client.Response => String) {
  /** @return response body as a string decoded as either the charset provided by
   *  Content-Type header of the response or ISO-8859-1 */
  def apply(r: client.Response) = r.getResponseBody

  /** @return a function that will return response body decoded in the provided charset */
  case class charset(set: Charset) extends (client.Response => String) {
    def apply(r: client.Response) = r.getResponseBody(set.name)
  }

  /** @return a function that will return response body as a utf8 decoded string */
  object utf8 extends charset(Charset.forName("utf8"))
}

object Bytes extends (client.Response => Array[Byte]) {
  def apply(r: client.Response) = r.getResponseBodyAsBytes
}

object File extends {
  def apply(file: java.io.File) =
    (new client.resumable.ResumableAsyncHandler with OkHandler[Nothing])
      .setResumableListener(
        new client.extra.ResumableRandomAccessFileListener(
          new java.io.RandomAccessFile(file, "rw")
        )
      )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy