diff --git a/CHANGELOG.md b/CHANGELOG.md index 18ca302..e5d38e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ChangeLog ------------------ * This package now supports sabre/event 3.0. +* The client now sets a default `User-Agent` header identifying this library. 4.1.0 (2015-09-04) diff --git a/lib/Client.php b/lib/Client.php index 40533fb..0810c4a 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -75,6 +75,7 @@ function __construct() { CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_NOBODY => false, + CURLOPT_USERAGENT => 'sabre-http/' . Version::VERSION . ' (http://sabre.io/)', ]; } diff --git a/tests/HTTP/ClientTest.php b/tests/HTTP/ClientTest.php index a9c9f30..ea25907 100644 --- a/tests/HTTP/ClientTest.php +++ b/tests/HTTP/ClientTest.php @@ -21,6 +21,7 @@ function testCreateCurlSettingsArrayGET() { CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_POSTFIELDS => '', CURLOPT_PUT => false, + CURLOPT_USERAGENT => 'sabre-http/' . Version::VERSION . ' (http://sabre.io/)', ]; // FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM @@ -50,6 +51,7 @@ function testCreateCurlSettingsArrayHEAD() { CURLOPT_URL => 'http://example.org/', CURLOPT_POSTFIELDS => '', CURLOPT_PUT => false, + CURLOPT_USERAGENT => 'sabre-http/' . Version::VERSION . ' (http://sabre.io/)', ]; // FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM @@ -85,6 +87,7 @@ function testCreateCurlSettingsArrayGETAfterHEAD() { CURLOPT_URL => 'http://example.org/', CURLOPT_POSTFIELDS => '', CURLOPT_PUT => false, + CURLOPT_USERAGENT => 'sabre-http/' . Version::VERSION . ' (http://sabre.io/)', ]; // FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM @@ -115,6 +118,7 @@ function testCreateCurlSettingsArrayPUTStream() { CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_HTTPHEADER => ['X-Foo: bar'], CURLOPT_URL => 'http://example.org/', + CURLOPT_USERAGENT => 'sabre-http/' . Version::VERSION . ' (http://sabre.io/)', ]; // FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM @@ -141,6 +145,7 @@ function testCreateCurlSettingsArrayPUTString() { CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_HTTPHEADER => ['X-Foo: bar'], CURLOPT_URL => 'http://example.org/', + CURLOPT_USERAGENT => 'sabre-http/' . Version::VERSION . ' (http://sabre.io/)', ]; // FIXME: CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS are currently unsupported by HHVM