private async void Go(object sender, RoutedEventArgs e) { #if __WASM__ var handler = new Uno.UI.Wasm.WasmHttpHandler(); #else var handler = new HttpClientHandler(); #endif try { using (handler) using (var client = new HttpClient(handler)) { Log("Creating a request message"); var request = new HttpRequestMessage(HttpMethod.Get, new Uri(address.Text)); Log("Sending request message"); var response = await client.SendAsync(request); Log("Reading from response"); var s = await response.Content.ReadAsStringAsync(); result.Text = s; } } catch (Exception ex) { while (ex != null) { Log($"Exception: {ex}\n\n"); ex = ex.InnerException; } } }
// Insert static constructor below here static WebApiBase() { #if __WASM__ var innerHandler = new Uno.UI.Wasm.WasmHttpHandler(); #else var innerHandler = new HttpClientHandler(); #endif _client = new HttpClient(innerHandler); }
static IdentityServerClient() { #if __WASM__ var innerHandler = new Uno.UI.Wasm.WasmHttpHandler(); #else var innerHandler = new HttpClientHandler(); #endif _client = new HttpClient(innerHandler); }
public CatsApi() { #if __WASM__ var innerHandler = new Uno.UI.Wasm.WasmHttpHandler(); #else var innerHandler = new HttpClientHandler(); #endif _httpClient = new HttpClient(innerHandler) { BaseAddress = new Uri(API_URL) }; _theCatsApi = RestService.For <ICatsApi>(_httpClient); }
public static bool Init() { if (_httpClient != null) { return(true); } #if __WASM__ var innerHandler = new Uno.UI.Wasm.WasmHttpHandler(); #else var innerHandler = new HttpClientHandler(); #endif _httpClient = new HttpClient(innerHandler); return(_httpClient != null); }
/// <summary> /// Override creation of HttpClient for wasm /// so the wasm instance is created based on /// the Uno WasmHttpHandler. /// </summary> /// <returns></returns> protected override HttpClient GetClient() { if (_client == null) { #if __WASM__ var handler = new Uno.UI.Wasm.WasmHttpHandler(); _client = new HttpClient(handler); #else _client = new HttpClient(); #endif } if (this.Timeout > 0) { _client.Timeout = TimeSpan.FromMilliseconds(this.Timeout); } return(_client); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { ConfigureFilters(global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory); #if !WINDOWS_UWP Uno.UI.FeatureConfiguration.Popup.UseNativePopup = false; // native doesn't display properly in android #endif this.InitializeComponent(); this.Suspending += OnSuspending; #if __WASM__ var handler = new Uno.UI.Wasm.WasmHttpHandler(); httpClient = new HttpClient(handler); #else httpClient = new HttpClient(); #endif Shared.Log.L("OnStart.begin"); }
partial void GetHttpMessageHandler(ref HttpMessageHandler handler) { handler = new Uno.UI.Wasm.WasmHttpHandler(); }