Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make HTTPS (not HTTP) request use akka-http?

Tags:

akka

akka-http

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?

like image 982
Maxim Avatar asked Jul 02 '15 13:07

Maxim


1 Answers

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

like image 182
S.Löwe Avatar answered Oct 09 '22 00:10

S.Löwe