public static async Task <HttpResponseMessage> GetAsync( this HttpClient client, string requestUri, HttpResponseMessage previousRequest = null) { HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Get, requestUri); if (previousRequest != null) { request.AddCookiesFromResponse(previousRequest); } return(await client.SendAsync(request)); }
public static async Task <HttpResponseMessage> PostFormAsync( this HttpClient client, string requestUri, IEnumerable <KeyValuePair <string, string> > form = null, HttpResponseMessage previousRequest = null) { HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Post, requestUri); if (form != null) { request.Content = new FormUrlEncodedContent(form); } if (previousRequest != null) { request.AddCookiesFromResponse(previousRequest); } return(await client.SendAsync(request)); }