2
2
namespace QuickBooksOnline \API \Core \HttpClients ;
3
3
4
4
use QuickBooksOnline \API \Exception \SdkException ;
5
+ use QuickBooksOnline \API \Core \CoreConstants ;
6
+
7
+
5
8
6
9
class IntuitResponse{
7
10
@@ -13,6 +16,8 @@ class IntuitResponse{
13
16
14
17
private $ faultHandler ;
15
18
19
+ private $ contentType ;
20
+
16
21
public function __construct ($ passedHeaders , $ passedBody , $ passedHttpResponseCode ){
17
22
if (isset ($ passedHeaders )){
18
23
$ this ->setHeaders ($ passedHeaders );
@@ -32,7 +37,7 @@ public function __construct($passedHeaders, $passedBody, $passedHttpResponseCode
32
37
$ this ->faultHandler = new FaultHandler ();
33
38
$ this ->faultHandler ->setHttpStatusCode ($ this ->httpResponseCode );
34
39
$ this ->faultHandler ->setResponseBody ($ this ->body );
35
- $ this ->faultHandler ->parseResponse ($ this ->body );
40
+ $ this ->faultHandler ->parseResponse ($ this ->body , $ this -> contentType );
36
41
//Manually set the error message
37
42
$ this ->faultHandler ->setOAuthHelperError ("Invalid auth/bad request (got a " .$ passedHttpResponseCode . ", expected HTTP/1.1 20X or a redirect) " );
38
43
}
@@ -50,11 +55,20 @@ public function setHeaders($rawHeaders){
50
55
}else {
51
56
list ($ key , $ value ) = explode (': ' , $ line );
52
57
$ this ->headers [$ key ] = $ value ;
58
+ //set response content type
59
+ $ this ->setContentType ($ key , $ value );
53
60
}
54
61
}
55
62
56
63
}
57
64
65
+ private function setContentType ($ key , $ val ){
66
+ $ trimedKey = trim ($ key );
67
+ if (strcasecmp ($ trimedKey , CoreConstants::CONTENT_TYPE ) == 0 ){
68
+ $ this ->contentType = trim ($ val );
69
+ }
70
+ }
71
+
58
72
public function getHeaders (){
59
73
return $ this ->headers ;
60
74
}
@@ -71,4 +85,8 @@ public function getFaultHandler(){
71
85
return $ this ->faultHandler ;
72
86
}
73
87
88
+ public function getResponseContentType (){
89
+ return $ this ->contentType ;
90
+ }
91
+
74
92
}
0 commit comments