Example #1
1
		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);
		}
Example #2
0
		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);
		}
Example #3
0
        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);

        }
Example #4
0
 /// <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());
 }
Example #5
0
 /// <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>());
 }
Example #6
0
 /// <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());
 }
Example #7
0
 /// <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());
 }
Example #8
0
 /// <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());
 }
Example #9
0
		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);
			}
		}