当响应header有多个set-cookie时会有问题
yljphp opened this issue · 0 comments
yljphp commented
使用fmt.Println(response.Raw)
获取,得到如下结果
&{200 OK 200 HTTP/1.1 1 1 map[Cache-Control:[private, must-revalidate] Connection:[keep-alive] Content-Type:[text/html; charset=UTF-8] Date:[Thu, 30 May 2019 06:35:03 GMT] Expires:[-1] Pragma:[no-cache] Server:[nginx] Set-Cookie:[XSRF-TOKEN=eyJpdiI6ImVZOThBVFlRZ3MzZmNsaVJmczd6Z3c9PSIsInZhbHVlIjoiSUdiSU5MblF0XC83N25iUXliMjNsNUlqTFE0MXpJQ3RLdU1LeGMrR1dmWG9pT25cL2hrd2I2ZG5iQlVnQVNTblJzZENCcm1LcTlcL3RVelZ3RFNmOWtkYlE9PSIsIm1hYyI6IjU2ZWU2MGY5NGE1OWJhNjBiZjM5YTFhNDgwMzJkNjViNDkxYmI2NGEyZmUzZGQ0N2NkNjhmZDQ5NDg2YTcyOGIifQ%3D%3D; expires=Thu, 13-Jun-2019 06:35:03 GMT; Max-Age=1209600; path=/ laravel_session=eyJpdiI6ImpPMTI0MHI2WnM2OGw2RERpN1NOaWc9PSIsInZhbHVlIjoiSjhkUUJ4TFdIN2VGSkFQd0NkcUZGXC90dkFZOG1oSE1wWGwwVnFLTm1qejVqN1VBSWlrNWdlck9ZQnQxbHRHMmVyZGdwUmlcL1hxXC9qaTY5QlFaTTNUNEE9PSIsIm1hYyI6IjI3NzA4OTZiOTcxNzFiZjM0MTgzNGNlYmMyMjc0NmY2MDJhNTUxNzRmM2YwMWNjNDQ0ODBkOTQ0NjJlMTU0Y2MifQ%3D%3D; expires=Thu, 13-Jun-2019 06:35:03 GMT; Max-Age=1209600; path=/; HttpOnly] Vary:[Accept-Encoding] X-Content-Type-Options:[nosniff]] 0xc0002349e0 -1 [chunked] false true map[] 0xc000110000 0xc0000d02c0}
使用fmt.Println(response.Headers)
获取,得到如下结果
map[Cache-Control:private, must-revalidate Connection:keep-alive Content-Type:text/html; charset=UTF-8 Date:Thu, 30 May 2019 06:35:03 GMT Expires:-1 Pragma:no-cache Server:nginx Set-Cookie:XSRF-TOKEN=eyJpdiI6ImVZOThBVFlRZ3MzZmNsaVJmczd6Z3c9PSIsInZhbHVlIjoiSUdiSU5MblF0XC83N25iUXliMjNsNUlqTFE0MXpJQ3RLdU1LeGMrR1dmWG9pT25cL2hrd2I2ZG5iQlVnQVNTblJzZENCcm1LcTlcL3RVelZ3RFNmOWtkYlE9PSIsIm1hYyI6IjU2ZWU2MGY5NGE1OWJhNjBiZjM5YTFhNDgwMzJkNjViNDkxYmI2NGEyZmUzZGQ0N2NkNjhmZDQ5NDg2YTcyOGIifQ%3D%3D; expires=Thu, 13-Jun-2019 06:35:03 GMT; Max-Age=1209600; path=/ Vary:Accept-Encoding X-Content-Type-Options:nosniff]
可以发现,laravel_session
消失了。
应该是下面这段代码的问题:
for k, v := range this.Raw.Header {
headers[k] = v[0]
}