[Foundation] Ensure that post requests are not cached by the native code.(#14729)
The behaviour from apple is wrong, PUT and POST are differnet in that PUT is idempotent. Calling PUT several times successively has the same effect (that is no side effect), where successive identical POST may have additional effects We should not let the native code cache the calls.
This commit is contained in:
Родитель
4c8d4457e5
Коммит
1f1189fae0
|
@ -857,7 +857,13 @@ namespace Foundation {
|
|||
[Preserve (Conditional = true)]
|
||||
public override void WillCacheResponse (NSUrlSession session, NSUrlSessionDataTask dataTask, NSCachedUrlResponse proposedResponse, Action<NSCachedUrlResponse> completionHandler)
|
||||
{
|
||||
completionHandler (sessionHandler.DisableCaching ? null! : proposedResponse);
|
||||
var inflight = GetInflightData (dataTask);
|
||||
|
||||
if (inflight is null)
|
||||
return;
|
||||
// apple caches post request with a body, which should not happen. https://github.com/xamarin/maccore/issues/2571
|
||||
var disableCache = sessionHandler.DisableCaching || (inflight.Request.Method == HttpMethod.Post && inflight.Request.Content is not null);
|
||||
completionHandler (disableCache ? null! : proposedResponse);
|
||||
}
|
||||
|
||||
[Preserve (Conditional = true)]
|
||||
|
|
Загрузка…
Ссылка в новой задаче