private async Task <TResponse> SendRequestAsync <TResponse>(IRequestBuilder <HttpRequestMessage> requestBuilder,
                                                                    Func <IResponseResolver, Task <TResponse> > resposneResolver, Boolean outOfProject = false, String project = null)
        {
            var credential = this.credentialProvider();

            var httpRequestMessage = requestBuilder
                                     .Authenticate(credential)
                                     .Sign(SignatureType.HmacSha1)
                                     .Build();

            if (outOfProject)
            {
                httpRequestMessage.Headers.Host = this.httpClient.BaseAddress.Host;
            }
            else if (project.IsNotEmpty())
            {
                httpRequestMessage.Headers.Host = $"{project}.{this.httpClient.BaseAddress.Host}";
                httpRequestMessage.RequestUri   =
                    new Uri($"{this.httpClient.BaseAddress.Scheme}://{project}.{this.httpClient.BaseAddress.Host}" +
                            $"{httpRequestMessage.RequestUri}");
            }

            var responseMessage = await this.httpClient.SendAsync(httpRequestMessage);

            return(await resposneResolver(HttpResponseMessageResolver.For(responseMessage)));
        }
Esempio n. 2
0
 internal TypedWrapper(HttpResponseMessageResolver innerResolver)
 {
     this.innerResolver = innerResolver;
 }