• API

    Show / Hide Table of Contents

    Class HttpClientBase

    Base class for Http clients.

    Inheritance
    System.Object
    HttpClientBase
    HttpReplicator
    Implements
    System.IDisposable
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Lucene.Net.Replicator.Http
    Assembly: Lucene.Net.Replicator.dll
    Syntax
    public abstract class HttpClientBase : IDisposable
    Remarks
    This is a Lucene.NET EXPERIMENTAL API, use at your own risk

    Constructors

    | Improve this Doc View Source

    HttpClientBase(String, Int32, String, HttpMessageHandler)

    Creates a new HttpClientBase with the given host, port and path.

    Declaration
    protected HttpClientBase(string host, int port, string path, HttpMessageHandler messageHandler = null)
    Parameters
    Type Name Description
    System.String host

    The host that the client should retrieve data from.

    System.Int32 port

    The port to be used to connect on.

    System.String path

    The path to the replicator on the host.

    System.Net.Http.HttpMessageHandler messageHandler

    Optional, The HTTP handler stack to use for sending requests, defaults to null.

    Remarks

    The host, port and path parameters are normalized to http://{host}:{port}{path}, if path is null or empty it defaults to /.

    A System.Net.Http.HttpMessageHandler is taken as an optional parameter as well, if this is not provided it defaults to null. In this case the internal System.Net.Http.HttpClient will default to use a System.Net.Http.HttpClientHandler.

    | Improve this Doc View Source

    HttpClientBase(String, HttpClient)

    Creates a new HttpClientBase with the given url and System.Net.Http.HttpClient.

    Declaration
    protected HttpClientBase(string url, HttpClient client)
    Parameters
    Type Name Description
    System.String url
    System.Net.Http.HttpClient client

    The System.Net.Http.HttpClient to use make remote http calls.

    Remarks

    This allows full controll over how the System.Net.Http.HttpClient is created, prefer the HttpClientBase(String, HttpMessageHandler) over this unless you know you need the control of the System.Net.Http.HttpClient.

    | Improve this Doc View Source

    HttpClientBase(String, HttpMessageHandler)

    Creates a new HttpClientBase with the given url.

    Declaration
    protected HttpClientBase(string url, HttpMessageHandler messageHandler = null)
    Parameters
    Type Name Description
    System.String url

    The full url, including with host, port and path.

    System.Net.Http.HttpMessageHandler messageHandler

    Optional, The HTTP handler stack to use for sending requests.

    Remarks

    A System.Net.Http.HttpMessageHandler is taken as an optional parameter as well, if this is not provided it defaults to null. In this case the internal System.Net.Http.HttpClient will default to use a System.Net.Http.HttpClientHandler.

    Fields

    | Improve this Doc View Source

    DEFAULT_CONNECTION_TIMEOUT

    Default connection timeout for this client, in milliseconds. ConnectionTimeout

    Declaration
    public const int DEFAULT_CONNECTION_TIMEOUT = 1000
    Field Value
    Type Description
    System.Int32

    Properties

    | Improve this Doc View Source

    ConnectionTimeout

    Gets or Sets the connection timeout for this client, in milliseconds. This setting is used to modify System.Net.Http.HttpClient.Timeout.

    Declaration
    public virtual int ConnectionTimeout { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    IsDisposed

    Returns true if this instance was Dispose(Boolean)ed, otherwise returns false. Note that if you override Dispose(Boolean), you must call Dispose(Boolean) on the base class, in order for this instance to be properly disposed.

    Declaration
    public bool IsDisposed { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Url

    The URL to execute requests against.

    Declaration
    protected string Url { get; }
    Property Value
    Type Description
    System.String

    Methods

    | Improve this Doc View Source

    Dispose()

    Disposes this HttpClientBase. This disposes the underlying System.Net.Http.HttpClient.

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    Dispose(Boolean)

    Disposes this HttpClientBase. When called with

    true
    , this disposes the underlying System.Net.Http.HttpClient.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    | Improve this Doc View Source

    DoAction<T>(HttpResponseMessage, Boolean, Func<T>)

    Do a specific action and validate after the action that the status is still OK, and if not, attempt to extract the actual server side exception. Optionally release the response at exit, depending on consume parameter.

    Declaration
    protected virtual T DoAction<T>(HttpResponseMessage response, bool consume, Func<T> call)
    Parameters
    Type Name Description
    System.Net.Http.HttpResponseMessage response
    System.Boolean consume
    System.Func<T> call
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    DoAction<T>(HttpResponseMessage, Func<T>)

    Calls the overload DoAction<T>(HttpResponseMessage, Boolean, Func<T>) passing true to consume.

    Declaration
    protected virtual T DoAction<T>(HttpResponseMessage response, Func<T> call)
    Parameters
    Type Name Description
    System.Net.Http.HttpResponseMessage response
    System.Func<T> call
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    EnsureOpen()

    Throws System.ObjectDisposedException if this client is already disposed.

    Declaration
    protected void EnsureOpen()
    Exceptions
    Type Condition
    System.ObjectDisposedException

    client is already disposed.

    | Improve this Doc View Source

    ExecuteGet(String, String[])

    Internal: Execute a request and return its result. The parameters argument is treated as: name1,value1,name2,value2,...

    Declaration
    protected virtual HttpResponseMessage ExecuteGet(string request, params string[] parameters)
    Parameters
    Type Name Description
    System.String request
    System.String[] parameters
    Returns
    Type Description
    System.Net.Http.HttpResponseMessage
    | Improve this Doc View Source

    ExecutePost(String, Object, String[])

    Internal: Execute a request and return its result. The parameters argument is treated as: name1,value1,name2,value2,...

    Declaration
    protected virtual HttpResponseMessage ExecutePost(string request, object entity, params string[] parameters)
    Parameters
    Type Name Description
    System.String request
    System.Object entity
    System.String[] parameters
    Returns
    Type Description
    System.Net.Http.HttpResponseMessage
    | Improve this Doc View Source

    ResponseInputStream(HttpResponseMessage)

    Internal utility: input stream of the provided response.

    Declaration
    public virtual Stream ResponseInputStream(HttpResponseMessage response)
    Parameters
    Type Name Description
    System.Net.Http.HttpResponseMessage response
    Returns
    Type Description
    System.IO.Stream
    Exceptions
    Type Condition
    System.IO.IOException
    | Improve this Doc View Source

    ResponseInputStream(HttpResponseMessage, Boolean)

    Internal utility: input stream of the provided response, which optionally consumes the response's resources when the input stream is exhausted.

    Declaration
    public virtual Stream ResponseInputStream(HttpResponseMessage response, bool consume)
    Parameters
    Type Name Description
    System.Net.Http.HttpResponseMessage response
    System.Boolean consume
    Returns
    Type Description
    System.IO.Stream
    Exceptions
    Type Condition
    System.IO.IOException
    | Improve this Doc View Source

    ThrowKnownError(HttpResponseMessage)

    Throws an exception for any errors.

    Declaration
    protected virtual void ThrowKnownError(HttpResponseMessage response)
    Parameters
    Type Name Description
    System.Net.Http.HttpResponseMessage response
    Exceptions
    Type Condition
    System.IO.IOException

    IO Error happened at the server, check inner exception for details.

    System.Net.Http.HttpRequestException

    Unknown error received from the server.

    | Improve this Doc View Source

    VerifyStatus(HttpResponseMessage)

    Internal: Verifies the response status and if not successful throws an exception.

    Declaration
    protected virtual void VerifyStatus(HttpResponseMessage response)
    Parameters
    Type Name Description
    System.Net.Http.HttpResponseMessage response
    Exceptions
    Type Condition
    System.IO.IOException

    IO Error happened at the server, check inner exception for details.

    System.Net.Http.HttpRequestException

    Unknown error received from the server.

    Implements

    System.IDisposable
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)