Salvaging .Net's HttpClient

Salvaging .Net's HttpClient

If you read [my previous article](, it's easy to become frustrated. HttpClient is at the core of everything we as software developers normally do when we integrate our...

If you read my previous article, it's easy to become frustrated. HttpClient is at the core of everything we as software developers normally do when we integrate our stuff with other people's stuff. Somebody sounding the alarm, telling you that it's fundamentally broken, might result in everything ranging from a general concern about ones own code, to flat out panic attacks. Hence, I figured I'd be an asshole unless I also showed you an alternative.

Paradoxically, fixing HttpClient is very easy, it's just to cut away everything in it that's dangerous, and encapsulate everything that's beautiful about it into a much safer API, making it impossible for developers to retrieve the instance to the HttpClient you're using internally. Basically, treat most of HttpClient's API as if it was cancer, and salvage the rest. Here's a much safer version in case you care. For the record, to understand this class, you have to read my previous article here at DZone.

As an additional bonus, it also automatically converts to and from request/response types automatically, using some intelligent generic constructs, allowing you to consume it in a much more "functional style". After all, HTTP is fundamentally a functional thing, and implementing too much OO constructs in it, is like using a hammer to fix your chimney. Check out basic usage of it below to understand what I mean.


Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install Dotnet Core on Ubuntu 18.04

How to Install Dotnet Core on Ubuntu 18.04. This tutorial is an walk through to install dotnet core on Ubuntu 18.04 Linux system. Also created a sample application using dotnet core.

Give Your .NET Object A Shot Of Lifeline [Tutorial]

In my previous post, I discussed the eager root collection as an aggressive behavior of JIT (in Release mode / optimized code) to assist the garbage collector (GC), so that a object is not considered to be a root beyond the point of its usage.

What is Dotnet?

**Introduction to .Net Framework:** <a href="">.*Net online training*</a> is a software framework that is designed and developed by Microsoft.Microsoft began developing the .net...

App Trimming in .NET 5: Reduce Your App Sizes Dramatically

In .NET Core 3, to resolve this issue, the .NET team introduced a tool that finds unused assemblies to remove them from final deployment.

Blazor Tutorial : Code Faster Using dotnet watch run - EP27

In this Blazor tutorial, I am showing how you can use "dotnet watch run" CLI command to code faster. "dotnet watch" keeps an eye on your project and looks for the changes that you are making. And then the only thing that you need to do is to reload the browser page.