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 4
4
use Http \Client \Common \PluginClient ;
5
5
use Http \Client \HttpClient ;
6
6
use Http \Discovery \HttpClientDiscovery ;
7
+ use Http \Client \Common \Exception \ServerErrorException ;
7
8
use Http \Client \Common \Plugin \ErrorPlugin ;
8
9
use Http \Discovery \MessageFactoryDiscovery ;
9
10
use Http \Message \Authentication \BasicAuth ;
@@ -33,7 +34,7 @@ class Client
33
34
protected $ userAgent ;
34
35
35
36
/** @var array Custom headers */
36
- protected $ headers ;
37
+ public $ headers ;
37
38
38
39
/**
39
40
* @var string|string[] Proxy configuration details.
@@ -66,7 +67,7 @@ public function __construct(
66
67
$ this ->url = $ url ;
67
68
$ options = $ options ?: array ();
68
69
69
- $ plugins = [new ErrorPlugin () ];
70
+ $ plugins = [];
70
71
71
72
$ this ->schema = isset ($ options ['schema ' ])
72
73
? $ options ['schema ' ]
@@ -214,6 +215,10 @@ public function request($method, $url)
214
215
$ request = $ this ->messageFactory ->createRequest ($ method , $ url , $ this ->headers );
215
216
$ response = $ this ->httpClient ->sendRequest ($ request );
216
217
218
+ if ($ response ->getStatusCode () >= 500 && $ response ->getStatusCode () < 600 ) {
219
+ throw new ServerErrorException ($ response ->getReasonPhrase (), $ request , $ response );
220
+ }
221
+
217
222
return (string ) $ response ->getBody ();
218
223
}
219
224
}
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ public function testHttpHeaders()
143
143
'user-agent ' => 'Blablabla/0.1 ' ,
144
144
));
145
145
146
- $ opts = $ sru1 ->getHttpHeaders () ;
146
+ $ opts = $ sru1 ->headers ;
147
147
148
148
$ this ->assertEquals ('application/xml ' , $ opts ['Accept ' ]);
149
149
$ this ->assertEquals ('Blablabla/0.1 ' , $ opts ['User-Agent ' ]);
You can’t perform that action at this time.
0 commit comments