HttpAsync Method
Definition
HttpAsync(HttpMethod, Uri, string, Stream, CancellationToken)
Send a request as an asynchronous operation.
public Task<HttpResponseMessage> HttpAsync(HttpMethod method, Uri location, string contentType, Stream content, CancellationToken ct = default)
Parameters
methodHttpMethodThe HTTP method.
locationUriThe Uri to request.
contentTypestringThe Content-Type header of the HTTP request sent to the server.
contentStreamThe HTTP request content sent to the server.
ctCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<HttpResponseMessage>
The task object representing the asynchronous operation.
Exceptions
- ArgumentNullException
methodcannot be null -or-locationcannot be null -or-contentTypecannot be null -or-contentcannot be null.
HttpAsync(HttpMethod, Uri, MediaTypeHeaderValue, Stream, CancellationToken)
Send a request as an asynchronous operation.
public Task<HttpResponseMessage> HttpAsync(HttpMethod method, Uri location, MediaTypeHeaderValue contentType, Stream content, CancellationToken ct = default)
Parameters
methodHttpMethodThe HTTP method.
locationUriThe Uri to request.
contentTypeMediaTypeHeaderValueThe Content-Type header of the HTTP request sent to the server.
contentStreamThe HTTP request content sent to the server.
ctCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<HttpResponseMessage>
The task object representing the asynchronous operation.
Exceptions
- ArgumentNullException
methodcannot be null -or-locationcannot be null -or-contentTypecannot be null -or-contentcannot be null.
HttpAsync(Uri, Action<HttpRequestOptions>)
Send a request as an asynchronous operation.
public virtual Task<HttpResponseMessage> HttpAsync(Uri location, Action<HttpRequestOptions> setup)
Parameters
locationUriThe Uri to request.
setupAction<HttpRequestOptions>The HttpRequestOptions which need to be configured.
Returns
- Task<HttpResponseMessage>
The task object representing the asynchronous operation.
Exceptions
- ArgumentNullException
locationcannot be null -or-setupcannot be null.