Skip to content

Commit e8c07d1

Browse files
committed
Merge pull request #543 from jamiehannaford/working
Adding explanation for prefixing user-agents
2 parents 8b2e6ee + 11ed0ad commit e8c07d1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/userguide/Clients.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,34 @@ To set default HTTP headers:
116116
$client->setDefaultOption('headers/X-Custom-Header', 'FooBar');
117117
```
118118

119+
## User agents
120+
121+
php-opencloud will send a default `User-Agent` header for every HTTP request, unless a custom value is provided by the end-user. The default header will be in this format:
122+
123+
> User-Agent: OpenCloud/xxx cURL/yyy PHP/zzz
124+
125+
where `xxx` is the current version of the SDK, `yyy` is the current version of cURL, and `zzz` is the current PHP version. To override this default, you must run:
126+
127+
```php
128+
$client->setUserAgent('MyCustomUserAgent');
129+
```
130+
131+
which will result in:
132+
133+
> User-Agent: MyCustomUserAgent
134+
135+
If you want to set a _prefix_ for the user agent, but retain the default `User-Agent` as a suffix, you must run:
136+
137+
```php
138+
$client->setUserAgent('MyPrefix', true);
139+
```
140+
141+
which will result in:
142+
143+
> User-Agent: MyPrefix OpenCloud/xxx cURL/yyy PHP/zzz
144+
145+
where `$client` is an instance of `OpenCloud\OpenStack` or `OpenCloud\Rackspace`.
146+
119147
## 5. Other functionality
120148

121149
For a full list of functionality provided by Guzzle, please consult the [official documentation](http://docs.guzzlephp.org/en/latest/http-client/client.html).

0 commit comments

Comments
 (0)