我可以通过以下方法将Cookie集合用作IRequestCookieCollection吗?如何将它们附加到请求?谢谢!
public static HttpClient GetHttpClient(string baseUri, IRequestCookieCollection cookies)
{
var cookieContainer = new CookieContainer();
var handler = new HttpClientHandler() { CookieContainer = cookieContainer };
var client = new HttpClient(handler) { BaseAddress = new Uri(baseUri) };
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//How to attach cookies to the request?
return client;
}