public static Task <ResponseMessage> GetAsync( this HttpTransporter httpTransporter, Uri requestUri, CancellationToken cancellationToken) { if (httpTransporter == null) { throw new ArgumentNullException(nameof(httpTransporter)); } var message = new RequestMessage( httpTransporter.ProtocolVersion, requestUri, HttpMethod.Get.ToString(), new HeaderCollection(HttpHeaderType.RequestHeader), null ); return(httpTransporter.SendAsync(message, cancellationToken)); }
public static async Task <ResponseMessage> SendAsync( this HttpTransporter httpTransporter, HttpMethod method, Uri requestUri, HttpRequestHeaders headers, HttpContent content, CancellationToken cancellationToken) { if (httpTransporter == null) { throw new ArgumentNullException(nameof(httpTransporter)); } var message = new RequestMessage( httpTransporter.ProtocolVersion, requestUri, method.ToString(), headers.ToHeaderCollection(), await content.ReadAsStreamAsync() ); return(await httpTransporter.SendAsync(message, cancellationToken)); }
public static Task <ResponseMessage> GetAsync(this HttpTransporter httpTransporter, string uri, CancellationToken cancellationToken) => GetAsync(httpTransporter, new Uri(uri), cancellationToken);