@@ -116,7 +116,7 @@ You can configure the global options using the ``default_options`` option:
116
116
<framework : config >
117
117
<framework : http-client >
118
118
<framework : default-options max-redirects =" 7" />
119
- </framework- http-client >
119
+ </framework : http-client >
120
120
</framework : config >
121
121
</container >
122
122
@@ -176,7 +176,7 @@ The HTTP client also has one configuration option called
176
176
<framework : config >
177
177
<framework : http-client max-host-connections =" 10" >
178
178
<!-- ... -->
179
- </framework- http-client >
179
+ </framework : http-client >
180
180
</framework : config >
181
181
</container >
182
182
@@ -495,8 +495,7 @@ associative array via the ``query`` option, that will be merged with the URL::
495
495
Headers
496
496
~~~~~~~
497
497
498
- Use the ``headers `` option to define both the default headers added to all
499
- requests and the specific headers for each request:
498
+ Use the ``headers `` option to define the default headers added to all requests:
500
499
501
500
.. configuration-block ::
502
501
@@ -505,8 +504,9 @@ requests and the specific headers for each request:
505
504
# config/packages/framework.yaml
506
505
framework :
507
506
http_client :
508
- headers :
509
- ' User-Agent ' : ' My Fancy App'
507
+ default_options :
508
+ headers :
509
+ ' User-Agent ' : ' My Fancy App'
510
510
511
511
.. code-block :: xml
512
512
@@ -521,8 +521,10 @@ requests and the specific headers for each request:
521
521
522
522
<framework : config >
523
523
<framework : http-client >
524
- <framework : header name =" User-Agent" >My Fancy App</framework : header >
525
- </framework-http-client >
524
+ <framework : default-options >
525
+ <framework : header name =" User-Agent" >My Fancy App</framework : header >
526
+ </framework : default-options >
527
+ </framework : http-client >
526
528
</framework : config >
527
529
</container >
528
530
@@ -531,8 +533,10 @@ requests and the specific headers for each request:
531
533
// config/packages/framework.php
532
534
$container->loadFromExtension('framework', [
533
535
'http_client' => [
534
- 'headers' => [
535
- 'User-Agent' => 'My Fancy App',
536
+ 'default_options' => [
537
+ 'headers' => [
538
+ 'User-Agent' => 'My Fancy App',
539
+ ],
536
540
],
537
541
],
538
542
]);
@@ -546,6 +550,8 @@ requests and the specific headers for each request:
546
550
],
547
551
]);
548
552
553
+ You can also set new headers or override the default ones for specific requests:
554
+
549
555
.. code-block :: php
550
556
551
557
// this header is only included in this request and overrides the value
@@ -865,7 +871,7 @@ To force HTTP/2 for ``http`` URLs, you need to enable it explicitly via the
865
871
<framework : config >
866
872
<framework : http-client >
867
873
<framework : default-options http-version =" 2.0" />
868
- </framework- http-client >
874
+ </framework : http-client >
869
875
</framework : config >
870
876
</container >
871
877
0 commit comments