Releases: scottoffen/fluenthttpclient
4.2.3
4.2.2
Update Default Version
The default Version on the HttpRequestMessage has been updated from 1.0 to 2.0.
Query Parameters
Updates how query parameters are added and stored in order to allow for multiple values for the same key. Previously, if a key was added twice, only the second value ended up in the query parameters.
Disable Chunked Transfer Encoding
When using the extension method WithJsonContent()
, the Content-Length header gets set to -1. In most cases, this is not an issue. In most cases, this is the desired and correct behavior. Occasionally it is not. See this issue for more information.
In those rare cases where this causes issues with the server you are communicating with, this behavior can now be disabled using the new DisableChunkedTransferEncoding()
extension method.
4.2.1
- Adds extensions for sending XML content
4.0.0
3.0.5
What's Changed
- Renamed the static class for global options to
FluentHttpClientOptions
by @scottoffen in #19
Full Changelog: 3.0.4...3.0.5
3.0.4
- Enables nullable in the csproj
- Adds an extension methods for
.WithQueryParam
that takes nullable objects. If the object is null, an empty string is added. If the object is not null, adds the result ofToString()
- Adds an extension method
HttpClient.WithoutRoute()
, set's the route to an empty string
3.0.3
3.0.2
Adds target for .Net 8.0
This version now targets .Net 6.0, .Net 7.0 and .Net 8.0
#8 Trailing Slashes Should Not Be Added When Route Is Empty
Fixes issue where trailing slash was being added if no value was provided for Route
.
To intentionally include a trailing slash, use a slash for the route instead of leaving it blank.
client.UsingRoute(); // no trailing slash
client.UsingRoute("/"); // includes trailing slash
#7 Add HttpRequestException Handler
You can now fluently add an exception handler for HttpRequestException
. When not used, the exception will be thrown without any behavior change. When used, the handler is called and a NullHttpResponseMessage
object is returned with a StatusCode of 0. The handler must be added before the request is sent.
var response = await _client
.UsingRoute("/user/list")
.WithQueryParam("sort", "desc")
.OnHttpRequestException(ex => { /* exception handling code here */ })
.GetAsync()
.OnFailure(msg => { success = false; })
.OnSuccess(msg => { success = true; });
This will only handle exceptions of type
HttpRequestException
. All other exception will be unhandled.
An extension method HttpRequestExceptionOccurred
on HttpResponseMessage
will return true if the object is the subclass NullHttpResponseMessage
. You do not need to check this in the OnSuccess
nor OnFailure
handlers, as neither OnSuccess
nor OnFailure
handlers will be called when the exception hander is used and an exception is throw, as both of those methods are specific to the response from the external service.
2.1.0
- Drops .NetStandard 2.0 target framework
- Adds .NET 7.0 target framework
- Adds support for XML deserialization
- Changes default value of
suppressException
to true
1.4.0
Merge pull request #1 from scottoffen/add-json-extensions Improve JSON support