TinyClient 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package TinyClient --version 1.0.3                
NuGet\Install-Package TinyClient -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TinyClient" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TinyClient --version 1.0.3                
#r "nuget: TinyClient, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TinyClient as a Cake Addin
#addin nuget:?package=TinyClient&version=1.0.3

// Install TinyClient as a Cake Tool
#tool nuget:?package=TinyClient&version=1.0.3                

TinyClient

Http client for .Net 4.0 framework (without bcl)

  • No bcl
  • Batching
  • Fluent style

Easy start example:

var client = new HttpClient("http://myHost.io");
var received = client.PostAndReceiveJson<MyAnswerVm>(
    query: "getMyAnswer", 
    jsonSerializeableContent:  new MyRequestVM { Name = "Bender"});
Console.WriteLine(received.Name);
//need no to close connection

A little more fluent example:

var answer = client
    .Create("localhost:8080")
    .Build()
    .SendJsonPost("users", new MyRequestVM {Name = "Bender"})
    .ThrowIfFailed()
    .GetJsonObject<MyAnswerVm>();

Console.WriteLine(answer.Name);

Masters of hardcore example:

var customClient = HttpClient
    .Create("http://myHost.io")
    .WithKeepAlive(true)
    .WithCustomDecoder(ClientEncoders.Deflate)
    .WithRequestTimeout(TimeSpan.FromSeconds(1))
    .WithRequestMiddleware((r) => r.AddCustomHeader("sentBy", "MasterOfHardcore"))
    .WithResponseMiddleware((r) => {
        if (r.StatusCode != HttpStatusCode.OK)
            throw new FormatException("Request failed with error: " + r.StatusCode);
    })
    .Build();

//request uri is http://myHost.io/search?text=What+up&attributes=all
var customRequest = HttpClientRequest
    .Create(HttpMethod.Post, "/search")
    .AddUriParam("text", "What up")
    .AddUriParam("attributes", "all")
    .AddCustomHeader("nugetPackage", "tinyClient")
    .AddCustomHeader("_SessionId", "42")
    .AddContentEncoder(ClientEncoders.Deflate)
    .SetKeepAlive(true)
    .SetTimeout(TimeSpan.FromSeconds(5))
    .SetContent(new JsonContent(new MyRequestVM {Name = "Cartman"}));

var textResponse = customClient
        .Send(customRequest) as HttpResponse<string>;

Console.WriteLine(textResponse?.Content);
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.2 933 12/6/2018
1.1.2 899 7/16/2018
1.1.1 1,022 3/26/2018
1.1.0 925 3/26/2018
1.0.8 956 3/16/2018
1.0.7 914 3/15/2018
1.0.6 951 3/2/2018
1.0.5 940 2/28/2018
1.0.4 901 2/16/2018
1.0.3 884 2/15/2018
1.0.2 931 2/8/2018
1.0.1 924 2/8/2018
1.0.0 943 2/8/2018

Additional helpers and batching support