docs.unity3d.com
    Show / Hide Table of Contents

    Class ServiceHttpClientExtensions

    Helper methods for IServiceHttpClient.

    Inheritance
    Object
    ServiceHttpClientExtensions
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Cloud.Common
    Syntax
    public static class ServiceHttpClientExtensions

    Methods

    CreateUri(String)

    Creates a from a specified String.

    Declaration
    public static Uri CreateUri(string uri)
    Parameters
    Type Name Description
    String uri

    The String to convert.

    Returns
    Type Description
    Uri

    The created .

    DeleteAsync(IServiceHttpClient, String, HttpContent, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous DELETE request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> DeleteAsync(this IServiceHttpClient httpClient, string requestUri, HttpContent content, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    String requestUri

    The uri for the request.

    HttpContent content

    The HTTP content for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    DeleteAsync(IServiceHttpClient, String, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous DELETE request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> DeleteAsync(this IServiceHttpClient httpClient, string requestUri, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    String requestUri

    The uri for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    DeleteAsync(IServiceHttpClient, Uri, HttpContent, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous DELETE request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> DeleteAsync(this IServiceHttpClient httpClient, Uri requestUri, HttpContent content, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    Uri requestUri

    The uri for the request.

    HttpContent content

    The HTTP content for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    DeleteAsync(IServiceHttpClient, Uri, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous DELETE request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> DeleteAsync(this IServiceHttpClient httpClient, Uri requestUri, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    Uri requestUri

    The uri for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    GetAsync(IServiceHttpClient, String, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous GET request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> GetAsync(this IServiceHttpClient httpClient, string requestUri, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    String requestUri

    The uri for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    GetAsync(IServiceHttpClient, Uri, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous GET request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> GetAsync(this IServiceHttpClient httpClient, Uri requestUri, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    Uri requestUri

    The uri for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    PostAsync(IServiceHttpClient, String, HttpContent, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous POST request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> PostAsync(this IServiceHttpClient httpClient, string requestUri, HttpContent content, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    String requestUri

    The uri for the request.

    HttpContent content

    The HTTP content for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    PostAsync(IServiceHttpClient, Uri, HttpContent, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous POST request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> PostAsync(this IServiceHttpClient httpClient, Uri requestUri, HttpContent content, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    Uri requestUri

    The uri for the request.

    HttpContent content

    The HTTP content for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    PutAsync(IServiceHttpClient, String, HttpContent, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous PUT request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> PutAsync(this IServiceHttpClient httpClient, string requestUri, HttpContent content, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    String requestUri

    The uri for the request.

    HttpContent content

    The HTTP content for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    PutAsync(IServiceHttpClient, Uri, HttpContent, ServiceHttpClientOptions, CancellationToken)

    Sends an asynchronous PUT request to the specified Uri.

    Declaration
    public static Task<HttpResponseMessage> PutAsync(this IServiceHttpClient httpClient, Uri requestUri, HttpContent content, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IServiceHttpClient httpClient

    The HTTP client.

    Uri requestUri

    The uri for the request.

    HttpContent content

    The HTTP content for the request.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<HttpResponseMessage>

    An HttpResponseMessage.

    WithApiSourceHeaders(IServiceHttpClient, String, String)

    Creates an instance of Unity.Cloud.Common.ServiceHttpClientHeaderModifier which adds the API source headers to each request.

    Declaration
    public static IServiceHttpClient WithApiSourceHeaders(this IServiceHttpClient baseServiceHttpClient, string name, string version)
    Parameters
    Type Name Description
    IServiceHttpClient baseServiceHttpClient

    The client for which to modify the request headers.

    String name

    The API source name.

    String version

    The API source version.

    Returns
    Type Description
    IServiceHttpClient

    The created Unity.Cloud.Common.ServiceHttpClientHeaderModifier.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown is name or version are null or empty.

    WithApiSourceHeadersFromAssembly(IServiceHttpClient, Assembly)

    Creates an instance of Unity.Cloud.Common.ServiceHttpClientHeaderModifier which adds the API source headers to each request. The source values are retrieved from the ApiSourceVersionAttribute which must be defined in the calling Assembly.

    Declaration
    public static IServiceHttpClient WithApiSourceHeadersFromAssembly(this IServiceHttpClient baseServiceHttpClient, Assembly assembly)
    Parameters
    Type Name Description
    IServiceHttpClient baseServiceHttpClient

    The client for which to modify the request headers.

    Assembly assembly

    The target assembly.

    Returns
    Type Description
    IServiceHttpClient

    The created Unity.Cloud.Common.ServiceHttpClientHeaderModifier.

    Remarks

    An instance of the ApiSourceVersionAttribute must be defined at the assembly-level in the calling Assembly in order for the correct API source values to be added as a header.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if assembly is null or the name or version defined in the retrieved ApiSourceVersionAttribute are null or white space.

    InvalidOperationException

    Thrown if ApiSourceVersionAttribute does not exist or is not initialized in the calling assembly.

    InvalidArgumentException

    Thrown if ApiSourceVersionAttribute is initialized with null or empty values in the calling assembly.

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023