6
votes

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?

1

1 Answers

4
votes

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