TinyClient 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TinyClient --version 1.0.1
NuGet\Install-Package TinyClient -Version 1.0.1
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.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TinyClient --version 1.0.1
#r "nuget: TinyClient, 1.0.1"
#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.1

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

TinyClient

Light Http client for .Net 4.0 framework (without bcl)

Example

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


//Custom way:
var customClient = HttpClient
    .Create("http://myHost.io")
    .WithKeepAlive(true)
    .WithRequestTimeout(TimeSpan.FromSeconds(1))
    .WithRequestMiddleware((r) => r.AddCustomHeader("sentBy", "customHeader"))
    .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")
    .SetKeepAlive(true)
    .SetTimeout(TimeSpan.FromSeconds(5))
    .SetContent(new JsonContent(new MyRequestVM {Name = "Cartman"}));

var response = customClient.Send(customRequest);
var textResponse = response 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 881 12/6/2018
1.1.2 872 7/16/2018
1.1.1 991 3/26/2018
1.1.0 901 3/26/2018
1.0.8 922 3/16/2018
1.0.7 880 3/15/2018
1.0.6 917 3/2/2018
1.0.5 905 2/28/2018
1.0.4 870 2/16/2018
1.0.3 857 2/15/2018
1.0.2 908 2/8/2018
1.0.1 894 2/8/2018
1.0.0 914 2/8/2018

Stabilization. Uri parse improvements