protected virtual async Task <ActionApiDescriptionModel> GetActionApiDescriptionModel(IAbpMethodInvocation invocation) { var clientConfig = ClientOptions.HttpClientProxies.GetOrDefault(typeof(TService)) ?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}."); var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync(clientConfig.RemoteServiceName); var client = HttpClientFactory.Create(clientConfig.RemoteServiceName); return(await ApiDescriptionFinder.FindActionAsync( client, remoteServiceConfig.BaseUrl, typeof(TService), invocation.Method )); }
public async Task <string> SendAsync(string url) { var client = HttpClientFactory.CreateClient(); var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); AddHeaders(requestMessage); var uri = new Uri(url, UriKind.RelativeOrAbsolute); if (!uri.IsAbsoluteUri) { var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); client.BaseAddress = new Uri(remoteServiceConfig.BaseUrl); await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, requestMessage, new RemoteServiceConfiguration(remoteServiceConfig.BaseUrl), string.Empty)); } var response = await client.SendAsync(requestMessage); return(await response.Content.ReadAsStringAsync()); }
public async Task <string> SendAsync(string url) { var client = HttpClientFactory.CreateClient(); var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); var uri = new Uri(url, UriKind.RelativeOrAbsolute); if (!uri.IsAbsoluteUri) { var baseUrl = string.Empty; try { //Blazor tiered -- mode var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); baseUrl = remoteServiceConfig.BaseUrl; client.BaseAddress = new Uri(baseUrl); AddHeaders(requestMessage); await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, requestMessage, new RemoteServiceConfiguration(baseUrl), string.Empty)); } catch (AbpException) // Blazor-Server mode. { baseUrl = NavigationManager.BaseUri; client.BaseAddress = new Uri(baseUrl); foreach (var header in HttpContextAccessor.HttpContext.Request.Headers) { requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()); } } } var response = await client.SendAsync(requestMessage); return(await response.Content.ReadAsStringAsync()); }