Class HttpRequestOptions
Specifies options that is related to HttpManager operations.
public class HttpRequestOptions : AsyncOptions, IAsyncOptions, IParameterObject
- Inheritance
-
HttpRequestOptions
- Implements
- Inherited Members
Examples
The following example demonstrates how to configure and send an HTTP request using HttpRequestOptions with the HttpManager.
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Cuemon.Net.Http;
using HttpRequestOptions = Cuemon.Net.Http.HttpRequestOptions;
namespace Examples;
public class HttpRequestExample
{
public async Task SendRequestAsync()
{
// Direct instantiation of HttpRequestOptions
var requestOptions = new HttpRequestOptions();
requestOptions.Request.Method = HttpMethod.Get;
using var manager = new HttpManager();
using var response = await manager.HttpAsync(
new Uri("https://api.example.com/data"),
o =>
{
o.Request.Method = HttpMethod.Get;
o.Request.Headers.Add("Accept", "application/json");
});
}
}
Constructors
HttpRequestOptions()
Initializes a new instance of the HttpRequestOptions class.
public HttpRequestOptions()
Properties
CompletionOption
Gets the recommended completion option of a response.
public HttpCompletionOption CompletionOption { get; }
Property Value
- HttpCompletionOption
The recommended completion option of a response.
Request
Gets the HTTP request message to send.
public HttpRequestMessage Request { get; }
Property Value
- HttpRequestMessage
The HTTP request message to send.