コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 public static Task <ResponseMessage> GetAsync(this HttpTransporter httpTransporter, string uri,
                                               CancellationToken cancellationToken) => GetAsync(httpTransporter, new Uri(uri), cancellationToken);