Skip to content

Releases: matteocontrini/PlainHttp

v2.1.0

19 Dec 14:14
b0b7842
Compare
Choose a tag to compare
  • Add AllowAutoRedirect option on HttpClientFactory (8b8f3ec)

v2.0.0

24 Jan 17:14
c0b8b90
Compare
Choose a tag to compare

Changes

  • Target framework updated to .NET 6.0 (b0eaebf)
  • Enabled nullable types (bf727f7)
  • Upgraded Flurl dependency (URL builder) to v4 (6098e03, d7d2a27)
  • New EnsureSuccessStatusCode method on the response (5f1c96b)
  • New StatusCode property on the response (4503c87)
  • IHttpClientFactory.GetProxiedClient() now has the request URI parameter too (06677e9)
  • New extensible payload serialization: introduced JsonPayload, XmlPayload, FormUrlEncodedPayload, PlainTextPayload and removed the ContentType property (924b708, 7548e3c)
  • Changed how responses can be read: removed ReadBody, DownloadFileName, ResponseEncoding properties from the request and added new Read* methods to the response
  • The default HttpClientFactory can now be customized without replacing it (bbb7cbb, 6a960d3)
  • The default constructor of HttpRequest was removed
  • The default value for the Timeout property on the request was changed from TimeSpan.Zero to System.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 on System.Text.Json)
  • XmlPayload (now with UTF-8 encoding instead of UTF-16)
  • FormUrlEncodedPayload
  • PlainTextPayload

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

01 Aug 17:00
Compare
Choose a tag to compare
  • Enable all response decompression methods by default (951d7c3)
  • Allow choosing HTTP version (5fe40fe)
  • Switch to System.Text.Json for JSON serialization (29f4e98)

v1.2.0

27 Nov 20:38
Compare
Choose a tag to compare
  • Changed target framework from .NET Core 2.2 to .NET Core 3.1, since 2.2 is not supported anymore and 3.1 is LTS (058001a)
  • Fix XML serialization not working (c500009)
  • Upgrade dependencies (b06947c)

v1.1.1

19 Jun 13:01
Compare
Choose a tag to compare
  • d32304e - Improve ReadBody by catching exceptions and considering timeout

v1.1.0

19 Jun 13:01
Compare
Choose a tag to compare
  • ce0dded - Add ReadBody and HttpCompletionOption request options

v1.0.3

12 Dec 09:11
Compare
Choose a tag to compare

808f9e4 - Add ConfigureAwait(false) in library code

v1.0.2

04 Dec 21:09
Compare
Choose a tag to compare

fb871fb - Add support for proxy credentials

v1.0.1

03 Oct 10:31
Compare
Choose a tag to compare

297e999 - Make some HttpClientFactory methods protected virtual

v1.0.0

03 Oct 10:30
Compare
Choose a tag to compare

Initial release