Skip to content

[API Proposal]:Add property to HttpClient #110555

@Mr0N

Description

@Mr0N

Background and motivation

I propose adding a property called ClientHandler to HttpClient, which would allow direct access to the underlying HttpClientHandler. When creating an instance of HttpClient, parameters like cookies or connection settings can be configured. However, once the object is passed to a class, there's no way to modify these settings further.

сlass Test(HttpClient client)
{
   public void Execute()
    {
     // In this class, it's impossible to configure cookies or other parameters
    }
}

API Proposal

class  HttpClient
{
    public HttpClientHandler ClientHandler {get;}
}

API Usage

var message = new HttpClientHandler();
var client = new HttpClient(message);

void Execute(HttpClient client)
{
    client.ClientHandler.CookieContainer = null;
}

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions