Skip to content

Add the API compatibility header in v8 #1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 21, 2022
Merged

Add the API compatibility header in v8 #1233

merged 6 commits into from
Jul 21, 2022

Conversation

ezimuel
Copy link
Contributor

@ezimuel ezimuel commented Jun 27, 2022

This PR adds the API compatibility header in client v8. This should solve issue #1221

@ezimuel ezimuel requested a review from technige June 28, 2022 13:39
@ezimuel
Copy link
Contributor Author

ezimuel commented Jun 28, 2022

@technige the PHP test are failing because we a license issue running Elasticsearch using elastic/elastic-github-actions/elasticsearch@master. The CI tests are ok.

Copy link

@technige technige left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -106,10 +107,12 @@ protected function addQueryString(string $url, array $params, array $keys): stri
*/
protected function bodySerialize($body, string $contentType): string
{
if (strpos($contentType, 'application/x-ndjson') !== false) {
if (strpos($contentType, 'application/x-ndjson') !== false ||

Choose a reason for hiding this comment

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

Is there ever a positive case when strpos(...) wouldn't just be 0, rather than just non-false? It's a weird (almost non-existent) edge case, but snapplication/x-ndjson or something similar would get through this?

So is there any reason why we couldn't change !== false to === 0, to tighten it up?

Alternatively, use str_starts_with to be even clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because 0 means application/x-ndjson is present in $contentType as the beginning of the string. Using false we are more safe, becuase we are sure that no substring is present.

@ezimuel ezimuel changed the base branch from 8.3 to master July 8, 2022 20:01
@ezimuel ezimuel merged commit bfd04a2 into elastic:master Jul 21, 2022
@NikosDevPhp
Copy link

@ezimuel Shouldn't this be optional, having a flag to control it?

We are currently trying to use client v.8 with server v.7.
I understand the compatibility header is for the other way around (working with server v.8 and client v.7) but I see requests are working okay in our setup without compatibility headers added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants