6

我正在使用以下代码向akka-httpAkka Actor 内部的库发出 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 协议。发送 HTTPS 请求使用是否正确或可能akka-http

4

1 回答 1

4

如果您查看官方文档,您可以看到您必须配置 HTTPS 上下文。然后它应该工作。

于 2015-07-02T14:07:47.620 回答