Exemple #1
0
        public Task <HttpResponseMessage> GetResponseAsync(HttpRequestMessage request, Stream stream, CancellationToken cancellationToken)
        {
            this.networkStream = stream as NetworkStream;
            this.commonStream  = stream;

            this.cancellationToken = cancellationToken;

            receiveHelper.Init(stream);

            response       = new HttpResponseMessage();
            contentHeaders = new Dictionary <string, List <string> >();

            response.RequestMessage = request;

            var task = Task.Run(() =>
            {
                ReceiveStartingLine();
                ReceiveHeaders();
                ReceiveContent();

                return(response);
            });

            return(task);
        }
        public async Task <HttpResponseMessage> GetResponseAsync(HttpRequestMessage request, Stream stream,
                                                                 CancellationToken cancellationToken = default)
        {
            networkStream = stream as NetworkStream;
            commonStream  = stream;

            receiveHelper.Init(stream);

            response       = new HttpResponseMessage();
            contentHeaders = new Dictionary <string, List <string> >();

            response.RequestMessage = request;

            await ReceiveFirstLineAsync(cancellationToken).ConfigureAwait(false);
            await ReceiveHeadersAsync(cancellationToken).ConfigureAwait(false);
            await ReceiveContentAsync(cancellationToken).ConfigureAwait(false);

            return(response);
        }