@@ -179,7 +179,8 @@ protected function setUri($uri) {
179
179
$ this ->keepAlive = true ;
180
180
$ this ->keepAliveTimeout = 300 ;
181
181
}
182
- private function initCurl ($ curl , $ request , $ timeout ) {
182
+ private function initCurl ($ curl , $ request , $ context ) {
183
+ $ timeout = $ context ->timeout ;
183
184
foreach ($ this ->options as $ name => $ value ) {
184
185
curl_setopt ($ curl , $ name , $ value );
185
186
}
@@ -202,6 +203,13 @@ private function initCurl($curl, $request, $timeout) {
202
203
foreach ($ this ->header as $ name => $ value ) {
203
204
$ headers_array [] = $ name . ": " . $ value ;
204
205
}
206
+ if (isset ($ context ->httpHeader )) {
207
+ $ header = $ context ->httpHeader ;
208
+ foreach ($ header as $ name => $ value ) {
209
+ $ headers_array [] = $ name . ": " .
210
+ (is_array ($ value ) ? join (", " , $ value ) : $ value );
211
+ }
212
+ }
205
213
curl_setopt ($ curl , CURLOPT_HTTPHEADER , $ headers_array );
206
214
if ($ this ->proxy ) {
207
215
curl_setopt ($ curl , CURLOPT_PROXY , $ this ->proxy );
@@ -242,7 +250,7 @@ private function initCurl($curl, $request, $timeout) {
242
250
}
243
251
private function syncSendAndReceive ($ request , stdClass $ context ) {
244
252
$ curl = curl_init ();
245
- $ this ->initCurl ($ curl , $ request , $ context-> timeout );
253
+ $ this ->initCurl ($ curl , $ request , $ context );
246
254
$ data = curl_exec ($ curl );
247
255
$ errno = curl_errno ($ curl );
248
256
if ($ errno ) {
@@ -255,7 +263,7 @@ private function syncSendAndReceive($request, stdClass $context) {
255
263
private function asyncSendAndReceive ($ request , stdClass $ context ) {
256
264
$ result = new Future ();
257
265
$ curl = curl_init ();
258
- $ this ->initCurl ($ curl , $ request , $ context-> timeout );
266
+ $ this ->initCurl ($ curl , $ request , $ context );
259
267
$ this ->curls [] = $ curl ;
260
268
$ this ->results [] = $ result ;
261
269
return $ result ;
0 commit comments