docs.unity3d.com
    Show / Hide Table of Contents

    Class ServiceHttpClient

    An implementation of an HTTP client which abstracts the Task of sending HttpRequestMessage.

    Inheritance
    Object
    ServiceHttpClient
    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 class ServiceHttpClient : IServiceHttpClient, IHttpClient

    Constructors

    ServiceHttpClient(IHttpClient, IAccessTokenProvider, IAppIdProvider)

    Initializes and returns an instance of ServiceHttpClient

    Declaration
    public ServiceHttpClient(IHttpClient baseHttpClient, IAccessTokenProvider accessTokenProvider, IAppIdProvider appIdProvider)
    Parameters
    Type Name Description
    IHttpClient baseHttpClient

    The base HTTP client.

    IAccessTokenProvider accessTokenProvider

    The access token provider to authenticate requests.

    IAppIdProvider appIdProvider

    The App ID provider.

    Properties

    Timeout

    The timespan to wait before the request times out.

    Declaration
    public TimeSpan Timeout { get; set; }
    Property Value
    Type Description
    TimeSpan
    Implements
    IHttpClient.Timeout

    Methods

    DownloadFileAsync(HttpRequestMessage, String, CancellationToken)

    Send an asynchronous a file download request.

    Declaration
    public Task<HttpResponseMessage> DownloadFileAsync(HttpRequestMessage request, string downloadFilePath, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    HttpRequestMessage request

    The request to be sent.

    String downloadFilePath

    Optional path to save downloaded files.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<HttpResponseMessage>

    A task that will hold the HttpResponseMessage once the request is completed

    Implements
    IHttpClient.DownloadFileAsync(HttpRequestMessage, String, CancellationToken)

    SendAsync(HttpRequestMessage, CancellationToken)

    Send an asynchronous HTTP request.

    Declaration
    public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    HttpRequestMessage request

    The request to be sent.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<HttpResponseMessage>

    A task that will hold the HttpResponseMessage once the request is completed

    Implements
    IHttpClient.SendAsync(HttpRequestMessage, CancellationToken)

    SendAsync(HttpRequestMessage, ServiceHttpClientOptions, CancellationToken)

    Send an asynchronous HTTP request.

    Declaration
    public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, ServiceHttpClientOptions options, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    HttpRequestMessage request

    The request to be sent.

    ServiceHttpClientOptions options

    The options for the client.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<HttpResponseMessage>

    A task that will hold the HttpResponseMessage once the request is completed

    Implements
    IServiceHttpClient.SendAsync(HttpRequestMessage, ServiceHttpClientOptions, CancellationToken)

    Extension Methods

    HttpClientExtensions.GetAsync(IHttpClient, String, CancellationToken)
    HttpClientExtensions.GetAsync(IHttpClient, Uri, CancellationToken)
    HttpClientExtensions.PostAsync(IHttpClient, String, HttpContent, String, CancellationToken)
    HttpClientExtensions.PostAsync(IHttpClient, Uri, HttpContent, String, CancellationToken)
    HttpClientExtensions.PutAsync(IHttpClient, String, HttpContent, CancellationToken)
    HttpClientExtensions.PutAsync(IHttpClient, Uri, HttpContent, CancellationToken)
    HttpClientExtensions.DeleteAsync(IHttpClient, String, CancellationToken)
    HttpClientExtensions.DeleteAsync(IHttpClient, Uri, CancellationToken)
    HttpClientExtensions.DeleteAsync(IHttpClient, String, HttpContent, CancellationToken)
    HttpClientExtensions.DeleteAsync(IHttpClient, Uri, HttpContent, CancellationToken)
    HttpClientExtensions.WithApiSourceHeaders(IHttpClient, String, String)
    HttpClientExtensions.WithApiSourceHeadersFromAssembly(IHttpClient, Assembly)
    HttpClientJsonExtensions.GetJsonAsync<TModel>(IHttpClient, String, CancellationToken)
    HttpClientJsonExtensions.PostJsonAsync<TModel>(IHttpClient, String, Object, CancellationToken)
    HttpClientJsonExtensions.PutJsonAsync<TModel>(IHttpClient, String, Object, CancellationToken)
    HttpClientJsonExtensions.DeleteJsonAsync<TModel>(IHttpClient, String, Object, CancellationToken)
    HttpClientJsonExtensions.DeleteJsonAsync(IHttpClient, String, Object, CancellationToken)
    ServiceHttpClientExtensions.GetAsync(IServiceHttpClient, String, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.GetAsync(IServiceHttpClient, Uri, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.PostAsync(IServiceHttpClient, String, HttpContent, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.PostAsync(IServiceHttpClient, Uri, HttpContent, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.PutAsync(IServiceHttpClient, String, HttpContent, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.PutAsync(IServiceHttpClient, Uri, HttpContent, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.DeleteAsync(IServiceHttpClient, String, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.DeleteAsync(IServiceHttpClient, Uri, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.DeleteAsync(IServiceHttpClient, String, HttpContent, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.DeleteAsync(IServiceHttpClient, Uri, HttpContent, ServiceHttpClientOptions, CancellationToken)
    ServiceHttpClientExtensions.WithApiSourceHeaders(IServiceHttpClient, String, String)
    ServiceHttpClientExtensions.WithApiSourceHeadersFromAssembly(IServiceHttpClient, 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