Correct way to configure ping options in yaml
bpastukh opened this issue · 3 comments
Hello!
I'm not sure I understood how I should configure ping extension options. According to HttpClientInterface::OPTIONS_DEFAULTS, it's
ping_on_success:
options:
json: { "text": "success" }
But in src/DependencyInjection/Configuration.php:331 options is configured as an array of scalar
->arrayNode('options')
->info('See HttpClientInterface::OPTIONS_DEFAULTS')
->scalarPrototype()->end()
->end()
So I tried this way:
ping_on_success:
options:
json: '{ "text": "success" }'
But HTTP client converts " to \u0022.
So I tried to use body option + content-type header
options:
body: '{ "text": "success" }'
headers: '{ "Content-Type": "application/json" }'
And now I have problems with headers:
In HttpClientTrait.php line 235:
[TypeError]
Argument 1 passed to Symfony\Component\HttpClient\CurlHttpClient::normalizeHeaders() must be of the type array, string given, called in /app/vendor/symfony/http-client/HttpClientTrait.php on line 162
So what's the correct way to configure ping options in yaml format?
Hey @bpastukh,
I think this should be considered a bug. I think what you want in your configuration is:
ping_on_success:
options:
json:
text: success
headers:
'Content-Type': application/json
For this to work, I think we need to change:
- ->scalarPrototype()->end()
+ ->variablePrototype()->end()
Could you try this in your local project and see if it works?
- ->scalarPrototype()->end()
+ ->variablePrototype()->end()
yes, it works, thank you!
btw, header 'Content-Type': application/json
is extra if we use json
option (it is set in HttpClientTrait.php:80) . So this config is correct:
ping_on_success:
options:
json:
text: success
btw, header 'Content-Type': application/json is extra if we use json option (it is set in HttpClientTrait.php:80) .
Oh yeah.
yes, it works, thank you!
Would you be up for creating a PR?