Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/userguide/Clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@ To set default HTTP headers:
$client->setDefaultOption('headers/X-Custom-Header', 'FooBar');
```

## User agents

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:

> User-Agent: OpenCloud/xxx cURL/yyy PHP/zzz

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:

```php
$client->setUserAgent('MyCustomUserAgent');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to show the user agent that will be sent over the wire in this case and the next (prefix) one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah me too, added

```

which will result in:

> User-Agent: MyCustomUserAgent

If you want to set a _prefix_ for the user agent, but retain the default `User-Agent` as a suffix, you must run:

```php
$client->setUserAgent('MyPrefix', true);
```

which will result in:

> User-Agent: MyPrefix OpenCloud/xxx cURL/yyy PHP/zzz

where `$client` is an instance of `OpenCloud\OpenStack` or `OpenCloud\Rackspace`.

## 5. Other functionality

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