Skip to content

Instantly share code, notes, and snippets.

@arschles
Last active December 24, 2015 02:59
Show Gist options
  • Save arschles/6733846 to your computer and use it in GitHub Desktop.
Save arschles/6733846 to your computer and use it in GitHub Desktop.
val host = "http://www.siliconvalley-codecamp.com/"
val url = new URL(host)
val client = ClientBuilder()
.codec(Http())
.hosts(host) //there are more params you can set here
.build()
val headers: Map[String, String] = ???
val method: Method = ??? // this is a org.jboss.netty.handler.codec.http.HttpMethod
val channelBuf: ChannelBuffer = ??? //this is a org.jboss.netty.buffer.ChannelBuffer
val req = RequestBuilder()
.url(url)
.addHeaders(headers)
.build(method, Some(channelBuf))
val respFuture: Future[HttpResponse] = client.apply(req) //client.apply(req) returns a com.twitter.util.Future
//do things with the response future
respFuture.ensure {
client.close()
}
@arschles
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment