Skip to content
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

Allow passing versioned media types to 7.x server #65362

Merged
merged 3 commits into from
Nov 25, 2020

Conversation

pgomulka
Copy link
Contributor

a follow up after #63071 where it missed the XContentType.fromMediaType
method.
That method also have to remove the vendor specific substrings
(vnd.elasticsearch+ and compatible-with parameter) from mediaType value

relates #51816

  • Have you signed the contributor license agreement?
  • Have you followed the contributor guidelines?
  • If submitting code, have you built your formula locally prior to submission with gradle check?
  • If submitting code, is your pull request against master? Unless there is a good reason otherwise, we prefer pull requests against master and will backport as needed.
  • If submitting code, have you checked that your submission is for an OS and architecture that we support?
  • If you are submitting this code for a class then read our policy for that.

a follow up after elastic#63071 where it missed the XContentType.fromMediaType
method.
That method also have to remove the vendor specific substrings
(vnd.elasticsearch+ and compatible-with parameter) from mediaType value

relates elastic#51816
@pgomulka pgomulka added :Core/Infra/REST API REST infrastructure and utilities v7.11.0 labels Nov 23, 2020
@pgomulka pgomulka self-assigned this Nov 23, 2020
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Nov 23, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@@ -151,7 +151,8 @@ public static XContentType fromMediaTypeOrFormat(String mediaType) {
private static String removeVersionInMediaType(String mediaType) {
if (mediaType.contains("vnd.elasticsearch")) {
return mediaType.replaceAll("vnd.elasticsearch\\+", "")
.replaceAll("\\s*;\\s*compatible-with=\\d+", "");
.replaceAll("\\s*;\\s*compatible-with=\\d+", "")
.replaceAll("\\s*;\\s*",";"); // to allow matching using startsWith
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I understand the comment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

matching in fromMediaTypeOrFormat can use startsWith so that
application/json; charset=utf-8 can be matched. however this assumes that ; is immediately following mediaTypeWithoutParameters

I don't want to refactor this in 7.x, the intention of .replaceAll("\\s*;\\s*",";"); was to make it slightly easier if you provided application/vnd.elasticsearch+json;compatible-with=7 ; charset=utf-8 with accidental space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the comment with a reference to a method

Copy link
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/REST API REST infrastructure and utilities >non-issue Team:Core/Infra Meta label for core/infra team v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants