Last active
August 29, 2015 14:24
-
-
Save julien-truffaut/8bbb76d836b4f49a844c to your computer and use it in GitHub Desktop.
Client error
This file contains hidden or 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
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