C# Class IBM.Cloudant.Client.HttpHelper

Internal class to manage the HTTP connection.
This class is used to manage HTTP requests and responses.
Show file Open project: cloudant/xamarin-cloudant Class Usage Examples

Public Methods

Method Description
AddGlobalHeader ( string name, string value ) : void

Adds global headers to the HttpClient.

DeleteAsync ( Uri uri, String>.Dictionary headers ) : Task

Sends an Http DELETE request to the given URI using the given headers.

GetAsync ( Uri uri, String>.Dictionary headers ) : Task

Sends a sends a HTTP GET request to the specified endpoint. Endpoint to send the request to. Additional headers to pass for the request

HttpHelper ( Uri baseUri ) : System

Initializes a new instance of the IBM.Cloudant.Client.HttpHelper class.

HttpHelper ( Uri baseUri, List requestInterceptors, List responseInterceptors ) : System

Initializes a new instance of the IBM.Cloudant.Client.HttpHelper class.

PostAsync ( Uri uri, String>.Dictionary headers, string body ) : Task

Sends an Http POST request to the given URI using the given headers and content.

PutAsync ( Uri uri, String>.Dictionary headers, string body ) : Task

Sends an Http PUT request to the given URI using the given headers and content.

RemoveGlobalHeader ( string name ) : void

Removes a header from the HttpClient global headers.

SetNumberOfRetries ( int numberOfRetries ) : void

Maximum number of times to rety a request when it has been intercepted and any interceptor sets the IBM.Cloudant.Client.HttpConnectionInterceptorContext.replayRequest flag to true.

Private Methods

Method Description
FormatAndSanitizeHeaders ( HttpHeaders headers ) : string

Removes password from Authentication header for safe logging.

FormatHttpRequestLog ( HttpRequestMessage request ) : string
FormatHttpResponseLog ( HttpResponseMessage response ) : string
FormatProperties ( object>.IDictionary props ) : string
SendJSONRequestAsync ( HttpMethod method, Uri uri, string>.Dictionary headers, string body ) : Task
SendRequestAsync ( HttpMethod method, Uri uri, string>.Dictionary headers, HttpContent content ) : Task

Method Details

AddGlobalHeader() public method

Adds global headers to the HttpClient.
public AddGlobalHeader ( string name, string value ) : void
name string Header name.
value string Header value.
return void

DeleteAsync() public method

Sends an Http DELETE request to the given URI using the given headers.
public DeleteAsync ( Uri uri, String>.Dictionary headers ) : Task
uri System.Uri URI for this request.
headers String>.Dictionary Http headers for this request.
return Task

GetAsync() public method

Sends a sends a HTTP GET request to the specified endpoint. Endpoint to send the request to. Additional headers to pass for the request
public GetAsync ( Uri uri, String>.Dictionary headers ) : Task
uri System.Uri
headers String>.Dictionary
return Task

HttpHelper() public method

Initializes a new instance of the IBM.Cloudant.Client.HttpHelper class.
public HttpHelper ( Uri baseUri ) : System
baseUri System.Uri Base URI for the HttpClient in this helper. All http requests must be relative to this URI.
return System

HttpHelper() public method

Initializes a new instance of the IBM.Cloudant.Client.HttpHelper class.
public HttpHelper ( Uri baseUri, List requestInterceptors, List responseInterceptors ) : System
baseUri System.Uri Base URI for the HttpClient in this helper. All http requests must be relative to this URI.
requestInterceptors List Request interceptors.
responseInterceptors List Response interceptors.
return System

PostAsync() public method

Sends an Http POST request to the given URI using the given headers and content.
public PostAsync ( Uri uri, String>.Dictionary headers, string body ) : Task
uri System.Uri URI for this request.
headers String>.Dictionary Http headers for this request.
body string The request contents.
return Task

PutAsync() public method

Sends an Http PUT request to the given URI using the given headers and content.
public PutAsync ( Uri uri, String>.Dictionary headers, string body ) : Task
uri System.Uri URI for this request.
headers String>.Dictionary Http headers for this request.
body string The request contents.
return Task

RemoveGlobalHeader() public method

Removes a header from the HttpClient global headers.
public RemoveGlobalHeader ( string name ) : void
name string Name.
return void

SetNumberOfRetries() public method

Maximum number of times to rety a request when it has been intercepted and any interceptor sets the IBM.Cloudant.Client.HttpConnectionInterceptorContext.replayRequest flag to true.
public SetNumberOfRetries ( int numberOfRetries ) : void
numberOfRetries int Number of retries.
return void