Releases: matteocontrini/PlainHttp
v2.1.0
v2.0.0
Changes
- Target framework updated to .NET 6.0 (b0eaebf)
- Enabled nullable types (bf727f7)
- Upgraded
Flurldependency (URL builder) to v4 (6098e03, d7d2a27) - New
EnsureSuccessStatusCodemethod on the response (5f1c96b) - New
StatusCodeproperty on the response (4503c87) IHttpClientFactory.GetProxiedClient()now has the request URI parameter too (06677e9)- New extensible payload serialization: introduced
JsonPayload,XmlPayload,FormUrlEncodedPayload,PlainTextPayloadand removed theContentTypeproperty (924b708, 7548e3c) - Changed how responses can be read: removed
ReadBody,DownloadFileName,ResponseEncodingproperties from the request and added newRead*methods to the response - The default
HttpClientFactorycan now be customized without replacing it (bbb7cbb, 6a960d3) - The default constructor of
HttpRequestwas removed - The default value for the
Timeoutproperty on the request was changed fromTimeSpan.ZerotoSystem.Threading.Timeout.InfiniteTimeSpan(9fa8d4c) - Exceptions now expose the request, response and elapsed time as properties (c4023db)
Upgrading from v1.x
Response reading and deserialization changes
If you used the Body property on the response, you should now use one of these methods to obtain the response:
Task<Stream> ReadStream()Task<string> ReadString()Task<string> ReadString(Encoding encoding)Task<T?> ReadJson<T>(JsonSerializerOptions? options = null)Task<string> DownloadFile(string path)Task<T?> ReadXml<T>(XmlReaderSettings? settings = null)Task<byte[]> ReadBytes()
All these methods except for ReadStream take into account the request timeout.
The updated README covers these methods, their usage and their pitfalls in greater detail.
Request serialization changes
If you used the request serialization feature, you should remove the ContentType property from requests and instead set the Payload with an instance of any class implementing the IPayload interface. Pass your payload to the constructor of these classes.
The library provides implementations for the following payload types:
JsonPayload(based onSystem.Text.Json)XmlPayload(now with UTF-8 encoding instead of UTF-16)FormUrlEncodedPayloadPlainTextPayload
With more likely coming in the future.
The updated README contains instructions on how to extend this mechanism and create new payload types.
Custom HttpClientFactorys
If you implemented your own IHttpClientFactory and/or inherited from HttpClientFactory, you must change the signature of the GetProxiedClient method as follows:
public HttpClient GetProxiedClient(Uri requestUri, Uri proxyUri)
Also, the default factory now allows for some basic customizations which weren't possible before without swapping the factory implementation. The updated README covers these new options in detail, which might remove the need for replacing the factory implementation altogether.
Default Timeout
If you relied on the fact that the default value of Timeout on HttpRequest was TimeSpan.Zero, the new default is System.Threading.Timeout.InfiniteTimeSpan (as it should always have been).
v1.3.0
v1.2.0
v1.1.1
v1.1.0
v1.0.3
v1.0.2
v1.0.1
v1.0.0
Initial release