Skip to content

Commit

Permalink
Fix the #237 and #236
Browse files Browse the repository at this point in the history
  • Loading branch information
hlu2 committed Jul 18, 2019
1 parent 01906e3 commit 6c9d703
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Core/HttpClients/IntuitResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
6 changes: 4 additions & 2 deletions src/Core/HttpClients/SyncRestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 6c9d703

Please # to comment.