Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Simple scala wrapper around jetty http client

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 project
Octocat-spinner-32 src
Octocat-spinner-32 README.md
README.md

Scala HTTP wrapper for Jetty HTTP client

Usage

Simple GET request:

import http._

...

Http(
  method = "GET"
  ,url = "http://google.com"
  ,onComplete = (status:Int, _, _) => println ("Google responded with "+status)
)

onComplete takes three arguments:

  • status:Int — HTTP response status
  • headers:Map[String,String] — HTTP response headers
  • stream:java.io.InputStream — Input stream with HTTP response body

Let's add some extra headers:

Http(
  ...
  ,headers = Map(
    "User-Agent"->"ScalaBOT 1.0"
    ,"Content-Type"->"application/json"
  )
)

Let's include a request body:

Http(
  ...
  ,content = Some(myInputStream)
)

Http.apply (...) returns a value of Future[Either[HttpError,T]] type, where T is the type returned by your onComplete function.

Something went wrong with that request. Please try again.