Skip to content

Commit

Permalink
Change default user-agent header
Browse files Browse the repository at this point in the history
Fixes #371.
  • Loading branch information
trowski committed Jan 12, 2025
1 parent f4c6c63 commit 20908f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/HttpClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct()
$this->followRedirectsInterceptor = new FollowRedirects(10);
$this->retryInterceptor = new RetryRequests(2);
$this->defaultAcceptInterceptor = new SetRequestHeaderIfUnset('accept', '*/*');
$this->defaultUserAgentInterceptor = new SetRequestHeaderIfUnset('user-agent', 'amphp/http-client @ v5.x');
$this->defaultUserAgentInterceptor = new SetRequestHeaderIfUnset('user-agent', 'amphp/http-client/5.x');
$this->defaultCompressionHandler = new DecompressResponse;
}

Expand Down
4 changes: 2 additions & 2 deletions test/ClientHttpBinIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function testDefaultUserAgentSent(): void
$body = $response->getBody()->buffer();
$result = \json_decode($body, true);

self::assertSame('amphp/http-client @ v5.x', $result['user-agent']);
self::assertSame('amphp/http-client/5.x', $result['user-agent']);
}

public function testDefaultUserAgentCanBeChanged(): void
Expand Down Expand Up @@ -206,7 +206,7 @@ public function testHeaderCase(): void
self::assertSame([
['tEst', 'test'],
['accept', '*/*'],
['user-agent', 'amphp/http-client @ v5.x'],
['user-agent', 'amphp/http-client/5.x'],
['Accept-Encoding', 'gzip, deflate, identity'],
['host', (string) $this->socket->getAddress()],
], $result);
Expand Down

0 comments on commit 20908f3

Please sign in to comment.