public async Task autodispose_true_creates_new_httpclients() { var fc = new FlurlClient("http://www.mysite.com", true); var x = await fc.GetAsync(); var y = await fc.GetAsync(); var z = await fc.GetAsync(); Assert.AreEqual(3, _fac.NewClientCount); }
public async Task autodispose_false_resues_httpclient() { var fc = new FlurlClient("http://www.mysite.com", false); var x = await fc.GetAsync(); var y = await fc.GetAsync(); var z = await fc.GetAsync(); Assert.AreEqual(1, _fac.NewClientCount); }
public void HelloIsHello() { var client = new FlurlClient(); client.Url = "http://localhost:80/TestWeb_deploy/test"; var response = client.GetAsync(); response.Result.StatusCode.Should().Be(HttpStatusCode.OK); }
/// <summary> /// Sends an asynchronous GET request and deserializes the JSON-formatted response body to a list of dynamic objects. /// </summary> /// <returns>A Task whose result is a list of dynamic objects containing data in the response body.</returns> public static Task <IList <dynamic> > GetJsonListAsync(this FlurlClient client) { return(client.GetAsync().ReceiveJsonList()); }
/// <summary> /// Sends an asynchronous GET request and deserializes the JSON-formatted response body to an object of type T. /// </summary> /// <typeparam name="T">A type whose structure matches the expected JSON response.</typeparam> /// <returns>A Task whose result is an object containing data in the response body.</returns> public static Task <T> GetJsonAsync <T>(this FlurlClient client) { return(client.GetAsync().ReceiveJson <T>()); }
/// <summary> /// Sends an asynchronous GET request and returns the response body as a byte array. /// </summary> /// <returns>A Task whose result is the response body.</returns> public static Task <byte[]> GetBytesAsync(this FlurlClient client) { return(client.GetAsync().ReceiveBytes()); }
/// <summary> /// Sends an asynchronous GET request and returns the response body as a stream. /// </summary> /// <returns>A Task whose result is the response body.</returns> public static Task <Stream> GetStreamAsync(this FlurlClient client) { return(client.GetAsync().ReceiveStream()); }
/// <summary> /// Sends an asynchronous GET request and returns the response body as a string. /// </summary> /// <returns>A Task whose result is the response body.</returns> public static Task <string> GetStringAsync(this FlurlClient client) { return(client.GetAsync().ReceiveString()); }
public async Task client_can_override_global_settings() { var overridden = false; using (new HttpTest()) { FlurlHttp.GlobalSettings.AfterCall = _ => overridden = false; var fc = new FlurlClient("http://www.api.com"); fc.Settings.AfterCall = _ => overridden = true; await fc.GetAsync(); Assert.True(overridden); } }