Flurl.Http 3.0
New Features
FlurlResponse
introduced, primarily to enable inspecting response and deserializing body in separate steps. (#354)- Major overhaul of cookie functionality. (#506)
- Overhaul of redirect handling. (#500)
- Tests can be set up to return different fake responses depending on the URL or any other request conditions. (#481)
HttpTest.ForCallsTo(...).AllowRealHttp()
for allowing real calls to be made in a test for specific URLs or any other request conditions. (#225)- New/more complete set of test assertions for headers and cookies. (#508)
- All extension methods on
Flurl.Url
andstring
are now also available onSystem.Uri
. (#489) - Providing a body for
PostAsync
,PutAsync
, andPatchAsync
now optional. (#515)
Breaking Changes from 2.x
Making HTTP calls
- Fluent methods that previously returned
HttpResponseMessage
(suchGetAsync
,PostAsync
, etc) now returnFlurlResponse
. If you're usingGetJsonAsync
or chainingReceiveXXX
methods, this shouldn't break anything. (#354) HttpCall
is nowFlurlCall
, and several properties ofFlurlCall
andFlurlHttpException
were moved or renamed. (#488)- Slightly different rules on when a redirect causes the verb to change to GET. (Never on 300, always on 303. #500)
- Minor changes to
CapturedStringContent
constructors. (#452)
Headers
- New collection type for
IFlurlRequest.Headers
andIFlurlClient.Headers
. (#541) HttpRequestMessage.GetHeaderValue
andHttpResponseMessage.GetHeaderValue
extension methods removed. (#553)- For multipart requests,
Content-Type
header for text parts allowed but not defaulted. (#452) Cookie
request header andSet-Cookie
response headers are always visible inHeaders
collection of request and response. (#506)
Cookies
CookiesEnabled
removed at all settings levels. (#506)Cookies
,WithCookie
andWithCookies
removed fromIFlurlClient
. UseCookieSession
instead. (#506)IFlurlRequest.Cookies
is now read-onlyIEnumerable<(string Name, string Value)>
. UseWithCookies
instead. (#506)
Testing
- When asserting a specific URL was called, it must be a full string match rather than "contains" or "starts with". Add a
*
wildcard to the beginning or end if you need partial match behavior. (#323) - When faking responses in tests, the last response in the queue becomes "sticky" rather than falling back to empty 200 responses. (#482)
HttpTest.ResponseQueue
public property has been removed. Underlying queue implementation changed significantly to support new features, and hopefully accessing it directly isn't needed. UseRespondWith
methods to build the queues.- Minor changes/enhancements to
HttpCallAssertion
. (#483)
Other
UseCookies
andAllowAutoRedirect
are disabled on the defaultHttpClientHandler
. Any custom factory-provided handler must do the same if Flurl's new cookie and redirect features are required. (#500 & #506)- Default
HttpClient
caching strategy based on host, scheme, and port, rather than just host. (#550) - Dropping support for older platforms. (#544)