From c2e14416f47309bd94bb583e67d8bacbb5733a67 Mon Sep 17 00:00:00 2001 From: Liam Cooper Date: Tue, 20 Apr 2021 14:02:01 +0100 Subject: [PATCH] Return location header as array if response is 303 --- lib/ShopifyResource.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ShopifyResource.php b/lib/ShopifyResource.php index 4c2262d..463958f 100644 --- a/lib/ShopifyResource.php +++ b/lib/ShopifyResource.php @@ -531,10 +531,15 @@ public function processResponse($responseArray, $dataKey = null) $httpOK = 200; //Request Successful, OK. $httpCreated = 201; //Create Successful. $httpDeleted = 204; //Delete Successful + $httpOther = 303; //See other (headers). //should be null if any other library used for http calls $httpCode = CurlRequest::$lastHttpCode; + if ($httpCode == $httpOther && array_key_exists('location', self::$lastHttpResponseHeaders)) { + return ['location' => self::$lastHttpResponseHeaders['location']]; + } + if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated && $httpCode != $httpDeleted) { throw new Exception\CurlException("Request failed with HTTP Code $httpCode.", $httpCode); }