Android 在燃料请求中正确设置cookie

Android 在燃料请求中正确设置cookie,android,cookies,fuel,Android,Cookies,Fuel,我正在尝试将cookie设置为成功身份验证后的所有get或post请求。身份验证请求返回带有设置cookie格式头值的响应 [accesstoken=sample_token; Version=1; Comment=secured; Domain=test.com; Max-Age=172800000; Expires=Mon, 07-Apr-2025 10:55:18 GMT; Path=] 对于web应用程序,我不必设置任何内容,xhr请求会自动处理附加cookie。此cookie还负责在

我正在尝试将cookie设置为成功身份验证后的所有get或post请求。身份验证请求返回带有
设置cookie
格式头值的响应

[accesstoken=sample_token; Version=1; Comment=secured; Domain=test.com; Max-Age=172800000; Expires=Mon, 07-Apr-2025 10:55:18 GMT; Path=]
对于web应用程序,我不必设置任何内容,xhr请求会自动处理附加cookie。此cookie还负责在后端识别用户。我在某个地方读到,cookie只是以
cookie
作为键值的头。因此,在成功身份验证之后,将从响应头中读取
Set cookie
头,格式如下

var cookeis = response.headers.get("Set-Cookie").toString()
接下来,在每个后续请求中将该值作为头追加

fun _POST(ctx: Context, path: String, query: List<Pair<String, String?>>): Request {
  var fuel = Fuel.post(ctx.getString(baseID)+path, query)
  val accesstoken = getCookie(ctx)

  when(accesstoken!=null){
    true ->  fuel = fuel.set(com.github.kittinunf.fuel.core.Headers.COOKIE,accesstoken)
    false -> {}
  }
return fuel
}
这将打印以前设置的相同cookie-

[accesstoken=sample_token; Version=1; Comment=secured; Domain=test.com; Max-Age=172800000; Expires=Mon, 07-Apr-2025 10:55:18 GMT; Path=]
但是服务器返回400响应状态。使用
react native
库开发应用程序时也使用了相同的api。在那里,xhr请求自动处理cookie管理


注意:我没有访问后端的权限。

我使用此代码发送单个传入cookie:

//响应来自前一个燃料柱
val cook=response.headers[“Set Cookie”].first()
燃料。获取(“https://mundraub.org/node/add/plant“”.header(要烹饪的Headers.COOKIE)
.responseString{request2,response2,result2->…}

我使用此代码发送单个传入cookie:

//响应来自前一个燃料柱
val cook=response.headers[“Set Cookie”].first()
燃料。获取(“https://mundraub.org/node/add/plant“”.header(要烹饪的Headers.COOKIE)
.responseString{request2,response2,result2->…}
[accesstoken=sample_token; Version=1; Comment=secured; Domain=test.com; Max-Age=172800000; Expires=Mon, 07-Apr-2025 10:55:18 GMT; Path=]