从Akka HttpResponse检索Cookie

时间:2016-08-17 00:44:01

标签: scala cookies akka akka-http

我正在尝试从Akka HttpResponse

中检索一个cookie
  

val httpRequest = HttpRequest(method = HttpMethods.POST,uri = uri,   实体=参数)       val responseFuture:Future [HttpResponse] = Http()。singleRequest(HttpRequest(uri = uri))

responseFuture2.flatMap { response =>
  println(response.entity)
  response.headers.collect {
    case hc =>
      println(hc)
  }
}

但是我无法在响应实体或响应标头中找到cookie值。我相信已经在akka中支持了cookie罐。 https://github.com/spray/spray/pull/311

有谁知道如何利用akka检索cookie?谢谢广告!

以下是我在python中的表现。

  

cookie_jar = cookielib.CookieJar()non_redirecting_opener =   urllib2.build_opener(NoRedirectionProcessor,   urllib2.HTTPCookieProcessor(cookie_jar))response =   non_redirecting_opener.open(request)cookies = {cookie.name:cookie   用于cookie_jar}中的cookie

1 个答案:

答案 0 :(得分:0)

它会做到这一点:

import pandas as pd
names =  pd.Series(["Mcgill", "Mcneill", "O'donnell", "Mctavish"])

names.replace(r'\bMc([a-z])', r'Mc\U$1', inplace=True)

但是你不应该直接对Future进行操作,而是通过actor系统发送它。