Fuuko is small library based on HttpClient class. It allows to make HTTP queries in declarative style (like Linq). The purpose of this project is to make the execution of HTTP requests easier. Supported synchronized and asynchronized execution.
The documentation is here
var response = RequestFactory.CreateRequest ()
.Url ( "https://www.google.ru/webhp" ) //define full url
.Method ( RequestMethod.Get ) // define HTTP method
.Parameter ( "q" , "cats" ) // define parameter q=cats
.Parameter ( "ie" , "UTF-8" ) // define parameter ie=UTF-8
.Send (); //send request synchronized
//output to console some response properties
Console.WriteLine ( "Content-Type: {0}" , response.Response.ContentType );
Console.WriteLine ( "Content-Length: {0}" , response.Response.ContentLength );
Console.WriteLine ( "Status: {0}" , response.Response.StatusCode );
Console.WriteLine ( "Protocol version: {0}" , response.Response.ProtocolVersion );
Console.WriteLine ( "Content: {0}" , response.GetContentAsString ( Encoding.UTF8 ) );
var request = RequestFactory.CreateRequest ()
.Url ( "https://example.com/" )
.Method ( RequestMethod.Get );
//synchronized variant
var arr = new int[] { 1 , 5, 10 };
// execute 3 query in loop
foreach (var item in arr){
var response = request
.Parameter ( "index" , item )
.Send ();
//output response
Console.WriteLine(response.GetContentAsString ( Encoding.UTF8 ));
}
//asynchronized variant
var tasks = arr.Select ( a =>
response
.Parameter ( "index" , a )
.SendAsync ()
);
//execute 3 query in parallels
var responses = await Task.WhenAll(tasks)
//output responses
foreach (var currentResponse in responses){
Console.WriteLine(currentResponse.GetContentAsString ( Encoding.UTF8 ));
}