Last active
December 24, 2015 02:59
-
-
Save arschles/6733846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
taken from https://github.com/stackmob/newman/blob/master/src/main/scala/com/stackmob/newman/FinagleHttpClient.scala
not shown here - maintaining a cache of clients. see https://groups.google.com/forum/#!searchin/finaglers/newman/finaglers/UcLoULgFwBU/DC5hkc7CgIcJ.
FinagleHttpClient
doesn't yet do that either