Skip to content

[API Proposal]: Add QUERY verb support to HttpClient #113522

Description

@MitchBodmer

Background and motivation

With the new QUERY verb reaching the Proposed Standard maturity level, now might be the right time to add it to HttpClient.

API Proposal

These methods added to HttpClient:

namespace System.Net.Http;

public partial class HttpClient : HttpMessageInvoker
{
    // Exactly the same shape as PostAsync, just replacing the method name
    public Task<HttpResponseMessage> QueryAsync([StringSyntax("Uri")] string? requestUri, HttpContent? content);
    public Task<HttpResponseMessage> QueryAsync([StringSyntax("Uri")] string? requestUri, HttpContent? content, CancellationToken cancellationToken);
    public Task<HttpResponseMessage> QueryAsync(Uri? requestUri, HttpContent? content);
    public Task<HttpResponseMessage> QueryAsync(Uri? requestUri, HttpContent? content, CancellationToken cancellationToken)
}

API Usage

This is intended to be used in the same way the current verbs with a body are used.

HttpClient httpClient = new();

var response = await httpClient.QueryAsync("https://myuri.com/path", someHttpContent);

Alternative Designs

No response

Risks

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions