我有以下代码,我想将标头的所有键和值(即 cookie、会话 id 等)存储在对象的 KeyValuepair 类型中。我怎样才能做到这一点?
CookieContainer cookies = new CookieContainer();
HttpClientHandler handler = new HttpClientHandler();
handler.CookieContainer = cookies;
HttpClient client = new HttpClient(handler);
HttpResponseMessage response = client.GetAsync("http://google.com").Result;
HttpHeaders headers = response.Headers;
我需要这些值,因为之后我将使用相同的 cookie 和 sessionid 发布到网站。