Exemplo n.º 1
0
        public async Task <HttpResponse> ExecuteAsync()
        {
            using (var client = new System.Net.Http.HttpClient(_messageHandler))
            {
                AddDefaults();

                _message.RequestUri = _baseAddress.AddPathParameters(
                    _path,
                    _pathParameters);

                _authenticator?.Authenticate(this);

                if (_message.Content == null)
                {
                    _parameterHandler.AddParameters(
                        _message,
                        MediaTypeEnum.Form,
                        _queryParameters);
                }
                else
                {
                    //TODO: allow content
                    throw new NotImplementedException();
                }

                var response = await client
                               .SendAsync(_message)
                               .ConfigureAwait(false);

                return(new HttpResponse(
                           response.Content,
                           response.Headers,
                           response.StatusCode,
                           response.ReasonPhrase,
                           GetSerializer(response)));
            }
        }