yii2-httpclient
yii2-httpclient copied to clipboard
Missing info in documentation
What steps will reproduce the problem?
Open https://github.com/yiisoft/yii2-httpclient/blob/master/docs/guide/basic-usage.md
What's expected?
Working examples for content-type: application/json
What do you get instead?
Not working examples
Additional info
You cannot just use ->addHeaders(['content-type' => 'application/json']) or ->setHeaders(['content-type' => 'application/json']) to enable this content-type. You mainly need to set the format $request->setFormat(Client::FORMAT_JSON) otherwise content-type application/x-www-form-urlencoded will be forced thanks to the defaultFormat Client::FORMAT_URLENCODED
| Q | A |
|---|---|
| Yii version | 2.0.50 |
| Yii HTTP Client version | ^2.0@dev |
| PHP version | 7.4.33 |
| Operating system | Debian GNU/Linux 11 (bullseye) |
Good catch. Do you have some time for a pull request?
I am not sure this is true. I just ran the following test with setHeaders and addHeaders and both works as described. I am running on PHP 8.3 though which has JSON included in core.