From 45f5514933d11de0e292b8ece72d0d48a8e863b7 Mon Sep 17 00:00:00 2001 From: Todd Menier Date: Sun, 3 Sep 2017 12:22:30 -0500 Subject: [PATCH] #208 better null handling when reading cookies --- src/Flurl.Http/FlurlRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Flurl.Http/FlurlRequest.cs b/src/Flurl.Http/FlurlRequest.cs index b930ff09..ca4cdd9a 100644 --- a/src/Flurl.Http/FlurlRequest.cs +++ b/src/Flurl.Http/FlurlRequest.cs @@ -161,9 +161,9 @@ private void WriteRequestCookies(HttpRequestMessage request) { } private void ReadResponseCookies(HttpResponseMessage response) { - if (response?.RequestMessage == null) return; - - var uri = response.RequestMessage.RequestUri; + var uri = response?.RequestMessage?.RequestUri; + if (uri == null) + return; // if the handler is an HttpClientHandler (which it usually is), it's already plucked the // cookies out of the headers and put them in the CookieContainer.