Skip to content

Commit 03ca033

Browse files
feature #50053 [BrowserKit][HttpClient] Update the value of some user agents to comply with the RFC 9110 specification (javiereguiluz)
This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [BrowserKit][HttpClient] Update the value of some user agents to comply with the RFC 9110 specification | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | fixes #50052 | License | MIT | Doc PR | - Commits ------- 722bd99 [BrowserKit][HttpClient] Update the value of some user agents to comply with the RFC 9110 specification
2 parents ff336fa + 722bd99 commit 03ca033

File tree

8 files changed

+32
-19
lines changed

8 files changed

+32
-19
lines changed

UPGRADE-6.3.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
UPGRADE FROM 6.2 to 6.3
22
=======================
33

4+
BrowserKit
5+
----------
6+
7+
* The default user agent has been renamed from `Symfony BrowserKit` to `SymfonyBrowserKit`
8+
to comply with the RFC 9110 specification
9+
410
Console
511
-------
612

@@ -60,6 +66,13 @@ FrameworkBundle
6066
* Deprecate the `notifier.logger_notification_listener` service, use the `notifier.notification_logger_listener` service instead
6167
* Deprecate the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead
6268

69+
HttpClient
70+
----------
71+
72+
* The default user agents have been renamed from `Symfony HttpClient/Amp`, `Symfony HttpClient/Curl`
73+
and `Symfony HttpClient/Native` to `SymfonyHttpClient (Amp)`, `SymfonyHttpClient (Curl)`
74+
and `SymfonyHttpClient (Native)` respectively to comply with the RFC 9110 specification
75+
6376
HttpFoundation
6477
--------------
6578

src/Symfony/Component/BrowserKit/AbstractBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function insulate(bool $insulated = true)
132132
public function setServerParameters(array $server)
133133
{
134134
$this->server = array_merge([
135-
'HTTP_USER_AGENT' => 'Symfony BrowserKit',
135+
'HTTP_USER_AGENT' => 'SymfonyBrowserKit',
136136
], $server);
137137
}
138138

src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public function testFollowRedirectWithHeaders()
508508
{
509509
$headers = [
510510
'HTTP_HOST' => 'www.example.com',
511-
'HTTP_USER_AGENT' => 'Symfony BrowserKit',
511+
'HTTP_USER_AGENT' => 'SymfonyBrowserKit',
512512
'CONTENT_TYPE' => 'application/vnd.custom+xml',
513513
'HTTPS' => false,
514514
];
@@ -535,7 +535,7 @@ public function testFollowRedirectWithPort()
535535
{
536536
$headers = [
537537
'HTTP_HOST' => 'www.example.com:8080',
538-
'HTTP_USER_AGENT' => 'Symfony BrowserKit',
538+
'HTTP_USER_AGENT' => 'SymfonyBrowserKit',
539539
'HTTPS' => false,
540540
'HTTP_REFERER' => 'http://www.example.com:8080/',
541541
];
@@ -755,7 +755,7 @@ public function testGetServerParameter()
755755
{
756756
$client = $this->getBrowser();
757757
$this->assertSame('', $client->getServerParameter('HTTP_HOST'));
758-
$this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
758+
$this->assertSame('SymfonyBrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
759759
$this->assertSame('testvalue', $client->getServerParameter('testkey', 'testvalue'));
760760
}
761761

@@ -764,7 +764,7 @@ public function testSetServerParameter()
764764
$client = $this->getBrowser();
765765

766766
$this->assertSame('', $client->getServerParameter('HTTP_HOST'));
767-
$this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
767+
$this->assertSame('SymfonyBrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
768768

769769
$client->setServerParameter('HTTP_HOST', 'testhost');
770770
$this->assertSame('testhost', $client->getServerParameter('HTTP_HOST'));
@@ -778,7 +778,7 @@ public function testSetServerParameterInRequest()
778778
$client = $this->getBrowser();
779779

780780
$this->assertSame('', $client->getServerParameter('HTTP_HOST'));
781-
$this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
781+
$this->assertSame('SymfonyBrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
782782

783783
$client->request('GET', 'https://www.example.com/https/www.example.com', [], [], [
784784
'HTTP_HOST' => 'testhost',
@@ -788,7 +788,7 @@ public function testSetServerParameterInRequest()
788788
]);
789789

790790
$this->assertSame('', $client->getServerParameter('HTTP_HOST'));
791-
$this->assertSame('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
791+
$this->assertSame('SymfonyBrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
792792

793793
$this->assertSame('https://www.example.com/https/www.example.com', $client->getRequest()->getUri());
794794

src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testRequestHeaders(array $requestArguments, array $expectedArgum
4242

4343
public static function validContentTypes()
4444
{
45-
$defaultHeaders = ['user-agent' => 'Symfony BrowserKit', 'host' => 'example.com'];
45+
$defaultHeaders = ['user-agent' => 'SymfonyBrowserKit', 'host' => 'example.com'];
4646
yield 'GET/HEAD' => [
4747
['GET', 'http://example.com/', ['key' => 'value']],
4848
['GET', 'http://example.com/', ['headers' => $defaultHeaders, 'body' => '', 'max_redirects' => 0]],

src/Symfony/Component/HttpClient/AmpHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function request(string $method, string $url, array $options = []): Respo
9898
}
9999

100100
if (!isset($options['normalized_headers']['user-agent'])) {
101-
$options['headers'][] = 'User-Agent: Symfony HttpClient/Amp';
101+
$options['headers'][] = 'User-Agent: SymfonyHttpClient (Amp)';
102102
}
103103

104104
if (0 < $options['max_duration']) {

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function request(string $method, string $url, array $options = []): Respo
9393
$url = implode('', $url);
9494

9595
if (!isset($options['normalized_headers']['user-agent'])) {
96-
$options['headers'][] = 'User-Agent: Symfony HttpClient/Curl';
96+
$options['headers'][] = 'User-Agent: SymfonyHttpClient (Curl)';
9797
}
9898

9999
$curlopts = [

src/Symfony/Component/HttpClient/NativeHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function request(string $method, string $url, array $options = []): Respo
191191
$this->logger?->info(sprintf('Request: "%s %s"', $method, implode('', $url)));
192192

193193
if (!isset($options['normalized_headers']['user-agent'])) {
194-
$options['headers'][] = 'User-Agent: Symfony HttpClient/Native';
194+
$options['headers'][] = 'User-Agent: SymfonyHttpClient (Native)';
195195
}
196196

197197
if (0 < $options['max_duration']) {

src/Symfony/Component/HttpClient/Tests/DataCollector/HttpClientDataCollectorTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public static function provideCurlRequests(): iterable
193193
--url %1$shttp://localhost:8057/json%1$s \\
194194
--header %1$sAccept: */*%1$s \\
195195
--header %1$sAccept-Encoding: gzip%1$s \\
196-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s',
196+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s',
197197
];
198198
yield 'GET with base uri' => [
199199
[
@@ -209,7 +209,7 @@ public static function provideCurlRequests(): iterable
209209
--url %1$shttp://localhost:8057/json/1%1$s \\
210210
--header %1$sAccept: */*%1$s \\
211211
--header %1$sAccept-Encoding: gzip%1$s \\
212-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s',
212+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s',
213213
];
214214
yield 'GET with resolve' => [
215215
[
@@ -229,7 +229,7 @@ public static function provideCurlRequests(): iterable
229229
--url %1$shttp://localhost:8057/json%1$s \\
230230
--header %1$sAccept: */*%1$s \\
231231
--header %1$sAccept-Encoding: gzip%1$s \\
232-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s',
232+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s',
233233
];
234234
yield 'POST with string body' => [
235235
[
@@ -247,7 +247,7 @@ public static function provideCurlRequests(): iterable
247247
--header %1$sContent-Length: 9%1$s \\
248248
--header %1$sContent-Type: application/x-www-form-urlencoded%1$s \\
249249
--header %1$sAccept-Encoding: gzip%1$s \\
250-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s \\
250+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s \\
251251
--data %1$sfoobarbaz%1$s',
252252
];
253253
yield 'POST with array body' => [
@@ -285,7 +285,7 @@ public function __toString(): string
285285
--header %1$sContent-Type: application/x-www-form-urlencoded%1$s \\
286286
--header %1$sContent-Length: 211%1$s \\
287287
--header %1$sAccept-Encoding: gzip%1$s \\
288-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s \\
288+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s \\
289289
--data %1$sfoo=fooval%1$s --data %1$sbar=barval%1$s --data %1$sbaz=bazval%1$s --data %1$sfoobar[baz]=bazval%1$s --data %1$sfoobar[qux]=quxval%1$s --data %1$sbazqux[0]=bazquxval1%1$s --data %1$sbazqux[1]=bazquxval2%1$s --data %1$sobject[fooprop]=foopropval%1$s --data %1$sobject[barprop]=barpropval%1$s --data %1$stostring=tostringval%1$s',
290290
];
291291

@@ -312,7 +312,7 @@ public function __toString(): string
312312
--url %1$shttp://localhost:8057/?foo=fooval&bar=newbarval&foobar[baz]=bazval&foobar[qux]=quxval&bazqux[0]=bazquxval1&bazqux[1]=bazquxval2%1$s \\
313313
--header %1$sAccept: */*%1$s \\
314314
--header %1$sAccept-Encoding: gzip%1$s \\
315-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s',
315+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s',
316316
];
317317
yield 'POST with json' => [
318318
[
@@ -336,7 +336,7 @@ public function __toString(): string
336336
--header %1$sAccept: */*%1$s \\
337337
--header %1$sContent-Length: 120%1$s \\
338338
--header %1$sAccept-Encoding: gzip%1$s \\
339-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s \\
339+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s \\
340340
--data %1$s{"foo":{"bar":"baz","qux":[1.1,1.0],"fred":["\u003Cfoo\u003E","\u0027bar\u0027","\u0022baz\u0022","\u0026blong\u0026"]}}%1$s',
341341
];
342342
}
@@ -368,7 +368,7 @@ public function testItDoesNotFollowRedirectionsWhenGeneratingCurlCommands()
368368
--header %1$sAccept: */*%1$s \\
369369
--header %1$sAuthorization: Basic Zm9vOmJhcg==%1$s \\
370370
--header %1$sAccept-Encoding: gzip%1$s \\
371-
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s', '\\' === \DIRECTORY_SEPARATOR ? '"' : "'"), $curlCommand
371+
--header %1$sUser-Agent: SymfonyHttpClient (Native)%1$s', '\\' === \DIRECTORY_SEPARATOR ? '"' : "'"), $curlCommand
372372
);
373373
}
374374

0 commit comments

Comments
 (0)