File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 44use Http \Client \Common \PluginClient ;
55use Http \Client \HttpClient ;
66use Http \Discovery \HttpClientDiscovery ;
7+ use Http \Client \Common \Exception \ServerErrorException ;
78use Http \Client \Common \Plugin \ErrorPlugin ;
89use Http \Discovery \MessageFactoryDiscovery ;
910use Http \Message \Authentication \BasicAuth ;
@@ -33,7 +34,7 @@ class Client
3334 protected $ userAgent ;
3435
3536 /** @var array Custom headers */
36- protected $ headers ;
37+ public $ headers ;
3738
3839 /**
3940 * @var string|string[] Proxy configuration details.
@@ -66,7 +67,7 @@ public function __construct(
6667 $ this ->url = $ url ;
6768 $ options = $ options ?: array ();
6869
69- $ plugins = [new ErrorPlugin () ];
70+ $ plugins = [];
7071
7172 $ this ->schema = isset ($ options ['schema ' ])
7273 ? $ options ['schema ' ]
@@ -214,6 +215,10 @@ public function request($method, $url)
214215 $ request = $ this ->messageFactory ->createRequest ($ method , $ url , $ this ->headers );
215216 $ response = $ this ->httpClient ->sendRequest ($ request );
216217
218+ if ($ response ->getStatusCode () >= 500 && $ response ->getStatusCode () < 600 ) {
219+ throw new ServerErrorException ($ response ->getReasonPhrase (), $ request , $ response );
220+ }
221+
217222 return (string ) $ response ->getBody ();
218223 }
219224}
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ public function testHttpHeaders()
143143 'user-agent ' => 'Blablabla/0.1 ' ,
144144 ));
145145
146- $ opts = $ sru1 ->getHttpHeaders () ;
146+ $ opts = $ sru1 ->headers ;
147147
148148 $ this ->assertEquals ('application/xml ' , $ opts ['Accept ' ]);
149149 $ this ->assertEquals ('Blablabla/0.1 ' , $ opts ['User-Agent ' ]);
You can’t perform that action at this time.
0 commit comments