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 SourceDefaultEncoding
The default encoding which is used wherever an encoding is specified. The default is set to Encoding.UTF8
Declaration
Encoding DefaultEncoding { get; }
Returns
Type | Description |
---|---|
System.Text.Encoding |
HttpCompletionOption
This can be used to change the behaviour of Http operation, default is to read the complete response.
Declaration
HttpCompletionOption HttpCompletionOption { get; }
Returns
Type | Description |
---|---|
System.Net.Http.HttpCompletionOption |
HttpContentConverters
This is the list of IHttpContentConverters which is used when converting from/to HttpContent
Declaration
IList<IHttpContentConverter> HttpContentConverters { get; }
Returns
Type | Description |
---|---|
System.Collections.Generic.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; }
Returns
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; }
Returns
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; }
Returns
Type | Description |
---|---|
System.Action<System.Net.Http.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; }
Returns
Type | Description |
---|---|
System.Func<System.Net.Http.HttpContent, System.Net.Http.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; }
Returns
Type | Description |
---|---|
System.Func<System.Net.Http.HttpMessageHandler, System.Net.Http.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 usefull, it can return a completely different HttpRequestMessage
Declaration
Func<HttpRequestMessage, HttpRequestMessage> OnHttpRequestMessageCreated { get; }
Returns
Type | Description |
---|---|
System.Func<System.Net.Http.HttpRequestMessage, System.Net.Http.HttpRequestMessage> |
ReadBufferSize
Specify the buffer for reading operations
Declaration
int ReadBufferSize { get; }
Returns
Type | Description |
---|---|
System.Int32 |
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; }
Returns
Type | Description |
---|---|
System.Boolean |
UploadProgress
IProgress for uploading, only used when using non-string content like Bitmaps or MemoryStreams. Also the UseProgressStreamContent needs to be true for detailed upload progress
Declaration
IProgress<float> UploadProgress { get; }
Returns
Type | Description |
---|---|
System.IProgress<System.Single> |
UseProgressStreamContent
Whenever a post is made to upload memorystream or bitmaps, this value is used to decide: true: ProgressStreamContent is used, instead of StreamContent
Declaration
bool UseProgressStreamContent { get; }
Returns
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; }
Returns
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceClone()
Clone this HttpBehavior and return an interface which can be used to write
Declaration
IChangeableHttpBehaviour Clone()
Returns
Type | Description |
---|---|
IChangeableHttpBehaviour | IChangeableHttpBehaviour |
MakeCurrent()
Set this IHttpBehaviour on the CallContext
Declaration
void MakeCurrent()