Skip to content

SimplyScala/http-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIMPLY SCALA HTTP CLIENT

This project provides a fast, asynchronous & and non-blocking http client API.
It encapsulate, in Scala 2.10 API, the project async-http-client

This works in a Java 6+ environment

The project is available in 0.2-SNAPSHOT version !

The actual project release version is 0.1

Roadmap

  • simple GET request OK (0.1)
  • simple POST request OK (0.1)
  • async api OK (0.1)
  • HEAD, PUT, DELETE request OK (0.1)
  • fluent API TODO
  • sync api TODO
  • proxy handling TODO
  • Akka actor plugin api TODO
  • other HTTP verb TODO
  • WebSocket TODO
  • SSL TODO
  • Response streaming TODO

Installation

Git repo

simplyscala-server is a SBT project.
It use 0.12 sbt version.

Maven dependency


   <dependency>
      <groupId>com.github.simplyscala</groupId>
      <artifactId>http-client_2.10</artifactId>
      <version>0.1</version>
   </dependency>

SBT dependency


    libraryDependencies += "com.github.simplyscala" %% "http-client" % "0.1"
Only the following Scala versions 2.10.x are currently supported.

Play! specific dependency management

In your play! project Build file :


    object ApplicationBuild extends Build {

        val appDependencies = Seq (
            "com.github.simplyscala" %% "http-client" % "0.1"
        )
    }

Simple JAR file

0.1 jar version

Try SNAPSHOT version

You could be tempted to try SNAPSHOT version to test project’s next features.

with Maven


<project ...>

   <repositories>
      <repository>
         <id>maven snapshot</id>
         <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      </repository>
   </repositories>

   ...

   <dependency>
      <groupId>com.github.simplyscala</groupId>
      <artifactId>http-client_2.10</artifactId>
      <version>0.2-SNAPSHOT</version>
    </dependency>

with SBT


   resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

   libraryDependencies += "com.github.simplyscala" %% "http-client" % "0.2-SNAPSHOT"

Usage

Simple GET HTTP request

val response: Future[Response] = new AsyncHttpClient().get("http://someUrl/path?param1=value1;param2=value2")

Simple POST HTTP request

val response: Future[Response] = new AsyncHttpClient().post("http://someUrl/path", Map("param" -> "value")

How to use scala.concurent.Future[+T] api

The AsyncHttpClient return asynchronous response. With Scala language, we use Future api.
When we perform, for example, GET request :
val response: Future[Response] = new AsyncHttpClient().get("http://github.com/simplyscala/http-client")

We are two major ways to use this result :

Callback api

// link to Future SIP & ScalaDoc

Monadic api

Blocking

If we use asynchronous api to perform HTTP request, it is not recommended to block the result. But sometimes, we must :D


import scala.concurrent.duration._
...

val futureResponse: Future[Response] = new AsyncHttpClient().get("http://github.com/simplyscala/http-client")
val response = Await.result(futureResponse, 1 second)

Releases

No releases published

Packages

No packages published

Languages