我使用以下代码在Akka Actor中向akka-http
库发出HTTP请求:
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
一切正常,但现在我想发出HTTPS请求(只需将http://
替换为https://
)。之后,content
变量将包含以下响应:
<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>
似乎akka-http
不支持HTTPS协议。使用akka-http
发送HTTPS请求是正确还是可能?