Class HttpService
Onbox's implementation for Http requests.
1 - Works with json strings for all serialzable objects
2 - IJsonService for json serialization
3 - Should be a singleton that is meant to be reused during the lifecycle of the application
4 - Provides strong typed response objects
5 - Provides request and response interception
Inheritance
System.Object
HttpService
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()
Assembly: Onbox.Core.dll
Syntax
public class HttpService : IHttpService, IDisposable
Constructors
|
Improve this Doc
View Source
HttpService(IJsonService, ILoggingService, IHttpInterceptor, HttpSettings)
Declaration
public HttpService(IJsonService jsonService, ILoggingService loggingService, IHttpInterceptor httpInterceptor, HttpSettings httpSettings)
Parameters
Methods
|
Improve this Doc
View Source
Add a header to all subsequent requests
Declaration
public IHttpService AddHeader(string name, string value)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.String |
value |
|
Returns
|
Improve this Doc
View Source
Clears all headers for all subsequent requests
Declaration
public IHttpService ClearHeaders()
Returns
|
Improve this Doc
View Source
DeleteAsync(String, String)
Send a DELETE request to the specified Uri as an asynchronous operation.
Declaration
public Task DeleteAsync(string endpoint, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
|
Improve this Doc
View Source
DeleteAsync<T>(String, String)
Send a DELETE request to the specified Uri and return the response body as an asynchronous operation.
Declaration
public Task<T> DeleteAsync<T>(string endpoint, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
|
Improve this Doc
View Source
Dispose()
Declaration
|
Improve this Doc
View Source
Finalize()
Declaration
protected void Finalize()
|
Improve this Doc
View Source
GetAsync<T>(String, String)
Send a GET request to the specified Uri as an asynchronous operation.
Declaration
public Task<T> GetAsync<T>(string endpoint, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
|
Improve this Doc
View Source
GetStreamAsync(String, String)
Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.
Declaration
public Task<Stream> GetStreamAsync(string endpoint, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.IO.Stream> |
|
|
Improve this Doc
View Source
PatchAsync(String, Object, String)
Send a PATCH request to the specified Uri as an asynchronous operation.
Declaration
public Task PatchAsync(string endpoint, object content, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
|
Improve this Doc
View Source
PatchAsync<T>(String, Object, String)
Send a PATCH request to the specified Uri and return the response body as an asynchronous operation.
Declaration
public Task<T> PatchAsync<T>(string endpoint, object content, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
|
Improve this Doc
View Source
PostAsync(String, Object, String)
Send a POST form request to the specified Uri and return the response body as an asynchronous operation.
Declaration
public Task PostAsync(string endpoint, object content, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
|
Improve this Doc
View Source
PostAsync<T>(String, Object, String)
Send a POST request to the specified Uri and return the response body as an asynchronous operation.
Declaration
public Task<T> PostAsync<T>(string endpoint, object content, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
|
Improve this Doc
View Source
PostFormAsync<T>(String, IDictionary<String, String>, String)
Send a POST request to the specified Uri and return the response body as a stream in an asynchronous operation.
Declaration
public Task<T> PostFormAsync<T>(string endpoint, IDictionary<string, string> content, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Collections.Generic.IDictionary<System.String, System.String> |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
|
Improve this Doc
View Source
PostRequestStreamAsync(String, Object, String)
Send a POST stream request to the specified Uri as an asynchronous operation.
Declaration
public Task<Stream> PostRequestStreamAsync(string endpoint, object content, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.IO.Stream> |
|
|
Improve this Doc
View Source
PostStreamAsync(String, Stream, String)
Send a POST stream request to the specified Uri and return the response body as an asynchronous operation.
Declaration
public Task PostStreamAsync(string endpoint, Stream content, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.IO.Stream |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
|
Improve this Doc
View Source
PostStreamAsync<T>(String, Stream, String)
Send a POST request to the specified Uri as an asynchronous operation.
Declaration
public Task<T> PostStreamAsync<T>(string endpoint, Stream content, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.IO.Stream |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
|
Improve this Doc
View Source
PutAsync(String, Object, String)
Send a PUT request to the specified Uri as an asynchronous operation.
Declaration
public Task PutAsync(string endpoint, object content, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
|
Improve this Doc
View Source
PutAsync<T>(String, Object, String)
Send a PUT request to the specified Uri and return the response body as an asynchronous operation.
Declaration
public Task<T> PutAsync<T>(string endpoint, object content, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
|
Improve this Doc
View Source
PutRequestStreamAsync(String, Object, String)
Send a PUT request to the specified Uri and return the response body as a stream in an asynchronous operation.
Declaration
public Task<Stream> PutRequestStreamAsync(string endpoint, object content, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.Object |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.IO.Stream> |
|
|
Improve this Doc
View Source
PutStreamAsync(String, Stream, String)
Send a PUT stream request to the specified Uri as an asynchronous operation.
Declaration
public Task PutStreamAsync(string endpoint, Stream content, string token = null)
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.IO.Stream |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
|
Improve this Doc
View Source
PutStreamAsync<T>(String, Stream, String)
Send a PUT stream request to the specified Uri and return the response body as an asynchronous operation.
Declaration
public Task<T> PutStreamAsync<T>(string endpoint, Stream content, string token = null)
where T : class
Parameters
Type |
Name |
Description |
System.String |
endpoint |
|
System.IO.Stream |
content |
|
System.String |
token |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<T> |
|
Type Parameters
Implements
System.IDisposable