6

I am using the following code to make HTTP request with akka-http library inside of Akka Actor:

implicit val materializer = ActorFlowMaterializer()
implicit val system = context.system

val request = HttpRequest(HttpMethods.GET, "http://ya.ru")
val content = for {
  response <- Http().singleRequest(request)
  content <- Unmarshal(response.entity).to[String]
} yield content

All works fine, but now I want to make HTTPS request (just replace http:// to https://). After that the content variable will contain the following response:

<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx</center>
</body>
</html>

Seems like akka-http doesn't support HTTPS protocol. Is it right or possible to send HTTPS request use akka-http?

Maxim
  • 9,701
  • 5
  • 60
  • 108

1 Answers1

4

If you take a look on the official documentation, you can see that you have to configure the HTTPS context. Then it should work.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
S.Löwe
  • 181
  • 4
  • I was using old version of `akka-http` (RC2 instead of RC4) and artifactId (`akka-http-scala-experimental` instead of `akka-http-experimental`) in my `build.sbt`. Your answer helped me to get it. – Maxim Jul 02 '15 at 14:44