Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala Akka Http无法读取响应正文?_Scala_Akka - Fatal编程技术网

Scala Akka Http无法读取响应正文?

Scala Akka Http无法读取响应正文?,scala,akka,Scala,Akka,我在scala/akka http项目中具有以下功能: def fetchResponse(userIdentifier: String, password: String): Future[HttpResponse] = { myResource(userIdentifier, password).map( result => if(result.status.intValue() == 201){ val bo

我在scala/akka http项目中具有以下功能:

  def fetchResponse(userIdentifier: String, password: String): Future[HttpResponse] = {
    myResource(userIdentifier, password).map(
      result =>
            if(result.status.intValue() == 201){
              val body = result.headers.collect {
                case c: `Set-Cookie` => c.cookie
              }.find(_.name == "SSO").getOrElse(HttpCookie("SSO", "")).value
              HttpResponse(result.status.intValue(), entity = body)
            }
            else {
             val body =
              result.httpMessage.entity().toString
              println(result)
              HttpResponse(result.status.intValue(),entity = body)
            }
    )

  }
此方法通过以下函数调用myMethod api:

 def myResource(userIdentifier:String,password:String): Future[HttpResponse] = {
    Http().singleRequest(HttpRequest(uri = Uri("http://localhost:9090/information"),
      method = HttpMethods.POST,
      entity = {
       FormData(Map("userIdentifier" -> userIdentifier, "password" -> password)).toEntity(HttpCharsets.`UTF-8`)
      }
    )
      .withHeaders(
        RawHeader("Content-Type", "application/x-www-form-urlencoded"),
        RawHeader("Accept", "application/vnd.siren+json")
      ))

  }
但是,当我从第一个函数中调用第二个函数时,它只返回响应状态,而不是返回如下的主体:

HttpEntity.Chunked(application/octet-stream)
将显示以下警告:

(WaitingForResponseEntitySubscription)] Response entity was not subscribed after 1 second. Make sure to read the response entity body or call `discardBytes()` on it.

我不知道是什么问题

我也有同样的问题。你把这个修好了吗?