Skip to content

Instantly share code, notes, and snippets.

@julien-truffaut
Last active August 29, 2015 14:24
Show Gist options
  • Save julien-truffaut/8bbb76d836b4f49a844c to your computer and use it in GitHub Desktop.
Save julien-truffaut/8bbb76d836b4f49a844c to your computer and use it in GitHub Desktop.
Client error
import org.http4s.Uri.{RegName, Authority, IPv4}
import org.http4s.client.blaze.SimpleHttp1Client
import org.http4s.dsl._
import org.http4s.server.HttpService
import org.http4s.server.blaze.BlazeBuilder
import org.http4s.{Request, Response, Uri}
import scala.concurrent.duration.Duration
object HttpServerApp extends App {
val service = HttpService {
case r @ POST -> Root / "plop" =>
Thread.sleep(1000 * 60)
Response(Ok).withBody("Plop")
}
BlazeBuilder
.mountService(service)
.bindHttp(5555, "0.0.0.0").start
.run
Thread.sleep(100000)
}
object HttpClientApp extends App {
val client = SimpleHttp1Client(timeout = Duration.Inf)
val request = client.prepare(Request(POST, Uri(
authority = Some(Authority(host = RegName("localhost"), port = Some(5555))),
path = s"/plop"
)))
request.run
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment