diff --git a/src/Core/HttpClients/IntuitResponse.php b/src/Core/HttpClients/IntuitResponse.php index 60a75451..72f20f9e 100644 --- a/src/Core/HttpClients/IntuitResponse.php +++ b/src/Core/HttpClients/IntuitResponse.php @@ -86,8 +86,9 @@ private function setResponseAsItIs($passedHeaders, $passedBody, $passedHttpRespo $this->headers = $passedHeaders; $this->body = $passedBody; $this->httpResponseCode = $passedHttpResponseCode; - $this->setContentType(CoreConstants::CONTENT_TYPE, $passedHeaders[CoreConstants::CONTENT_TYPE]); - $this->setIntuitTid(CoreConstants::INTUIT_TID, $passedHeaders[CoreConstants::INTUIT_TID]); + $passedHeaders = array_change_key_case($passedHeaders, CASE_LOWER); + $this->setContentType(CoreConstants::CONTENT_TYPE, $passedHeaders[strtolower(CoreConstants::CONTENT_TYPE)]); + $this->setIntuitTid(CoreConstants::INTUIT_TID, $passedHeaders[strtolower(CoreConstants::INTUIT_TID)]); $this->setFaultHandler($passedBody, $passedHttpResponseCode, $this->getIntuitTid()); }else{ throw new SdkException("Passed Headers, body, or status code is Null."); diff --git a/src/Core/HttpClients/SyncRestHandler.php b/src/Core/HttpClients/SyncRestHandler.php index e9e9a595..efaa8bd2 100644 --- a/src/Core/HttpClients/SyncRestHandler.php +++ b/src/Core/HttpClients/SyncRestHandler.php @@ -206,6 +206,7 @@ private function OAuth2APICall($baseURL, $queryParameters, $HttpMethod, $request $intuitResponse = $this->httpClientInterface->makeAPICall($requestUri, $HttpMethod, $httpHeaders, $requestBody, null, true); $faultHandler = $intuitResponse->getFaultHandler(); $this->LogAPIResponseToLog($intuitResponse->getBody(), $requestUri, $intuitResponse->getHeaders()); + //Based on the ducomentation, the fetch expected HTTP/1.1 20X or a redirect. If not, any 3xx, 4xx or 5xx will throw an OAuth Exception //for 3xx without direct, it will throw a 503 code and error saying: Invalid protected resource url, unable to generate signature base string if($faultHandler) { @@ -267,8 +268,9 @@ private function setCommonHeadersForPHPSDK($AuthorizationHeader, $requestUri, $C * @param Array $httpHeaders The headers for the request */ public function LogAPIResponseToLog($body, $requestUri, $httpHeaders){ - if(strcasecmp($httpHeaders[CoreConstants::CONTENT_TYPE], CoreConstants::CONTENTTYPE_APPLICATIONXML) == 0 || - strcasecmp($httpHeaders[CoreConstants::CONTENT_TYPE], CoreConstants::CONTENTTYPE_APPLICATIONXML_WITH_CHARSET) == 0){ + $httpHeaders = array_change_key_case($httpHeaders, CASE_LOWER); + if(strcasecmp($httpHeaders[strtolower(CoreConstants::CONTENT_TYPE)], CoreConstants::CONTENTTYPE_APPLICATIONXML) == 0 || + strcasecmp($httpHeaders[strtolower(CoreConstants::CONTENT_TYPE)], CoreConstants::CONTENTTYPE_APPLICATIONXML_WITH_CHARSET) == 0){ $body = $this->parseStringToDom($body); }