How to parse a cookie string

后端 未结 9 1903
眼角桃花
眼角桃花 2020-12-08 04:47

I would like to take a Cookie string (as it might be returned in a Set-Cookie header) and be able to easily modify parts of it, specifically the expiration date.

I s

9条回答
  •  半阙折子戏
    2020-12-08 05:04

            val headers = ..........
    
    
            val headerBuilder = Headers.Builder()
    
            headers?.forEach {
                val values = it.split(";")
                values.forEach { v ->
                    if (v.contains("=")) {
                        headerBuilder.add(v.replace("=", ":"))
                    }
                }
            }
    
            val headers = headerBuilder.build()
    

提交回复
热议问题