An HTTP Server and Client library for Scala.
Clone or download
guillaumebort Replace Netty by Blaze (#64)
Replace Netty by Blaze

Netty being pushed based and lolhttp pull based, a lot of complexity
was hidden in the Netty integration. Migration were painful as this
code was super sensible to race conditions.

This commit replace the underlying network & http codec implementation
by http4s blaze. At the same time we upgrade cats, cats-effect & fs2

- HTTP/2 support is not promoted anymore for now. It is somehow supported
by blaze but it requires ALPN support that is not widely supported in Java
for now. We will introduce it back later.

- Protocol upgrade in user-land API has been removed. It was never used
and I'm not sure anymore that it is useful as new protocol seems to
favor ALPN anyway.

- Auto follow-redirect is not supported anymore when re-using  a client
directly connected to an host. It does not make sense as redirect to
another host is perfectly legit but it can't be handled if the client is
connected to a singel host. It was a bug in the initial design.
Latest commit aa9b5cb Sep 7, 2018


An HTTP Server and Client library for Scala.

About the library

A server is built from a plain function accepting an HTTP request and eventually giving back an HTTP response. The computation is wrapped into an effect and can handle pure & impure and synchronous & asynchronous scenarios. Requests and responses are just HTTP metadata along with a lazy content body based on fs2, making it easy to handle streaming scenarios if needed. For additional convenience, the library provides content encoders and decoders for the common scala types. Clients and Servers share the same API and the same concepts, making it easy to compose them. SSL is supported on both sides.

Hello World

// Let's start an HTTP server
Server.listen(8888) {
  case GET at "/hello" =>
    Ok("Hello World!")
  case _ =>

// Let's connect with an HTTP client
Client.runSync(Get("http://localhost:8888/hello")) { res =>
  res.readAs[String].map { contentBody =>
    println(s"Received: $contentBody")


The library is cross-built for Scala 2.11 and Scala 2.12.

The core module to use is "com.criteo.lolhttp" %% "lolhttp" % "0.11.0".

There are also 2 optional companion libraries:

  • "com.criteo.lolhttp" %% "loljson" % "0.11.0", provides integration with the circe JSON library.
  • "com.criteo.lolhttp" %% "lolhtml" % "0.11.0", provides minimal HTML templating.


The API documentation is the main reference.

If you never used cats effects before, you should start by having a quick look at it. Service Responses must be wrapped into an IO (although there is an implicit conversion translating Response into a pure IO if needed). Also consuming the underlying content stream data is an effect. For asynchronous scenarios you have to deal with asynchronous effects, unless you prefer working with Future and wrapping it at the end using IO.fromFuture.

If you need to access the underlying content stream, you should first have a look a the fs2 documentation to understand the basics.

For those who prefer documentation by example, you can also follow these hands-on introductions:


This project is licensed under the Apache 2.0 license.


Copyright © Criteo, 2018.