Class HttpClientBase
Base class for Http clients.
Namespace: Lucene.Net.Replicator.Http
Assembly: Lucene.Net.Replicator.dll
Syntax
public abstract class HttpClientBase : IDisposable
Remarks
Constructors
| Improve this Doc View SourceHttpClientBase(String, HttpClient)
Creates a new Httpurl
and
Declaration
protected HttpClientBase(string url, HttpClient client)
Parameters
Type | Name | Description |
---|---|---|
System. |
url | |
Http |
client | The |
Remarks
This allows full controll over how the
HttpClientBase(String, HttpMessageHandler)
Creates a new Httpurl
.
Declaration
protected HttpClientBase(string url, HttpMessageHandler messageHandler = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
url | The full url, including with host, port and path. |
Http |
messageHandler | Optional, The HTTP handler stack to use for sending requests. |
Remarks
A null
.
In this case the internal
HttpClientBase(String, Int32, String, HttpMessageHandler)
Creates a new Http
Declaration
protected HttpClientBase(string host, int port, string path, HttpMessageHandler messageHandler = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
host | The host that the client should retrieve data from. |
System. |
port | The port to be used to connect on. |
System. |
path | The path to the replicator on the host. |
Http |
messageHandler | Optional, The HTTP handler stack to use for sending requests, defaults to |
Remarks
The host, port and path parameters are normalized to http://{host}:{port}{path}
,
if path is null
or empty
it defaults to /
.
A null
.
In this case the internal
Fields
| Improve this Doc View SourceDEFAULT_CONNECTION_TIMEOUT
Default connection timeout for this client, in milliseconds.
Connection
Declaration
public const int DEFAULT_CONNECTION_TIMEOUT = null
Field Value
Type | Description |
---|---|
System. |
Properties
| Improve this Doc View SourceConnectionTimeout
Gets or Sets the connection timeout for this client, in milliseconds. This setting
is used to modify
Declaration
public virtual int ConnectionTimeout { get; set; }
Property Value
Type | Description |
---|---|
System. |
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. |
Url
The URL to execute requests against.
Declaration
protected string Url { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
| Improve this Doc View SourceDispose()
Disposes this Http
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System. |
disposing |
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 |
---|---|---|
Http |
response | |
Func<T> | call |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
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 |
---|---|---|
Http |
response | |
System. |
consume | |
Func<T> | call |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
EnsureOpen()
Throws
Declaration
protected void EnsureOpen()
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. |
request | |
System. |
parameters |
Returns
Type | Description |
---|---|
Http |
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. |
request | |
System. |
entity | |
System. |
parameters |
Returns
Type | Description |
---|---|
Http |
ResponseInputStream(HttpResponseMessage)
Internal utility: input stream of the provided response.
Declaration
public virtual Stream ResponseInputStream(HttpResponseMessage response)
Parameters
Type | Name | Description |
---|---|---|
Http |
response |
Returns
Type | Description |
---|---|
Stream |
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 |
---|---|---|
Http |
response | |
System. |
consume |
Returns
Type | Description |
---|---|
Stream |
ThrowKnownError(HttpResponseMessage)
Throws an exception for any errors.
Declaration
protected virtual void ThrowKnownError(HttpResponseMessage response)
Parameters
Type | Name | Description |
---|---|---|
Http |
response |
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 |
---|---|---|
Http |
response |