Interface IHttpBehaviour
The IHttpBehaviour is used to control the behaviour of all operations in the HttpExtensions library.
Namespace: Dapplo.HttpExtensions
Assembly: Dapplo.HttpExtensions.dll
Syntax
public interface IHttpBehaviour
Properties
| Improve this Doc View SourceCookieContainer
This cookie container will be assessed when creating the HttpMessageHandler and HttpSettings.UseCookies is true
Declaration
CookieContainer CookieContainer { get; }
Property Value
Type | Description |
---|---|
CookieContainer |
DefaultEncoding
The default encoding which is used wherever an encoding is specified. The default is set to Encoding.UTF8
Declaration
Encoding DefaultEncoding { get; }
Property Value
Type | Description |
---|---|
Encoding |
DownloadProgress
Action which is called to notify of download progress. Only used when using non-string content like Bitmaps or MemoryStreams. Also the UseProgressStream needs to be true for this download progress
Declaration
Action<float> DownloadProgress { get; }
Property Value
Type | Description |
---|---|
Action<System.Single> |
HttpCompletionOption
This can be used to change the behaviour of Http operation, default is to read the complete response.
Declaration
HttpCompletionOption HttpCompletionOption { get; }
Property Value
Type | Description |
---|---|
HttpCompletionOption |
HttpContentConverters
This is the list of IHttpContentConverters which is used when converting from/to HttpContent
Declaration
IList<IHttpContentConverter> HttpContentConverters { get; }
Property Value
Type | Description |
---|---|
IList<IHttpContentConverter> |
HttpSettings
Pass your HttpSettings here, which will be used to create the HttpClient If not specified, the HttpSettings.GlobalSettings will be used
Declaration
IHttpSettings HttpSettings { get; }
Property Value
Type | Description |
---|---|
IHttpSettings |
JsonSerializer
This is used to de- serialize Json, can be overwritten by your own implementation. By default, also when empty, the SimpleJsonSerializer is used.
Declaration
IJsonSerializer JsonSerializer { get; }
Property Value
Type | Description |
---|---|
IJsonSerializer |
OnHttpClientCreated
An action which can modify the HttpClient which is generated in the HttpClientFactory. Use cases for this, might be adding a header or other settings for specific cases
Declaration
Action<HttpClient> OnHttpClientCreated { get; }
Property Value
Type | Description |
---|---|
Action<HttpClient> |
OnHttpContentCreated
An Func which can modify the HttpContent right before it's used to start the request. This can be used to add a specific header, e.g. set a filename etc, or return a completely different HttpContent type
Declaration
Func<HttpContent, HttpContent> OnHttpContentCreated { get; }
Property Value
Type | Description |
---|---|
Func<HttpContent, HttpContent> |
OnHttpMessageHandlerCreated
An Func which can modify or wrap the HttpMessageHandler which is generated in the HttpMessageHandlerFactory. Use cases for this, might be if you have very specify settings which can't be set via the IHttpSettings Or you want to add additional behaviour (extend DelegatingHandler!!) like the OAuthDelegatingHandler
Declaration
Func<HttpMessageHandler, HttpMessageHandler> OnHttpMessageHandlerCreated { get; }
Property Value
Type | Description |
---|---|
Func<HttpMessageHandler, HttpMessageHandler> |
OnHttpRequestMessageCreated
An Func which can modify the HttpRequestMessage right before it's used to start the request. This can be used to add a specific header, which should not be for all requests. As the called func has access to HttpRequestMessage with the content, uri and method this is quite useful, it can return a completely different HttpRequestMessage
Declaration
Func<HttpRequestMessage, HttpRequestMessage> OnHttpRequestMessageCreated { get; }
Property Value
Type | Description |
---|---|
Func<HttpRequestMessage, HttpRequestMessage> |
ReadBufferSize
Specify the buffer for reading operations
Declaration
int ReadBufferSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
RequestConfigurations
Configuration for different parts of the library, or your own implementations, which can be set on a thread/request base. For missing configurations the default is taken.
Declaration
IDictionary<string, IHttpRequestConfiguration> RequestConfigurations { get; }
Property Value
Type | Description |
---|---|
IDictionary<System.String, IHttpRequestConfiguration> |
ThrowOnError
If a request gets a response which has a HTTP status code which is an error, it would normally THROW an exception. Sometimes you would still want the response, settings this to false would allow this. This can be ignored for all HttpResponse returning methods.
Declaration
bool ThrowOnError { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
UploadProgress
Action which is called to notify of upload progress, be sure to handle the UI thread issues yourself. Only used when using non-string content like Bitmaps or MemoryStreams. Also the UseProgressStream needs to be true for this upload progress
Declaration
Action<float> UploadProgress { get; }
Property Value
Type | Description |
---|---|
Action<System.Single> |
UseProgressStream
Whenever a post is made to upload memory stream or bitmaps, this value is used to decide: true: ProgressStream is used, instead of Stream
Declaration
bool UseProgressStream { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ValidateResponseContentType
Check if the response has the expected content-type, when servers are used that are not following specifications this should be set to false
Declaration
bool ValidateResponseContentType { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceMakeCurrent()
Set this IHttpBehaviour on the CallContext
Declaration
void MakeCurrent()
ShallowClone()
Make a memberwise clone of the object, this is "shallow".
Declaration
IChangeableHttpBehaviour ShallowClone()
Returns
Type | Description |
---|---|
IChangeableHttpBehaviour | "Shallow" Cloned instance of IChangeableHttpBehaviour |