Skip to content

Make ContentTypeReplacer smarter #756

Closed

Description

@jvherweg

If we have a resource with content-type application/ld+json and we get a request with accept header application/json, the ContentTypeReplacer is going to identify that this is a valid response.

But if we have a resource with content-type text/turtle, an error is going to be thrown that the request is not supported, even though we could provide a valid response by converting that turtle to json.

One possible solution would be for the ContentTypeReplacer to update the incoming preferences to also include support the types it is configured with. E.g., in the example above it would see that the preferences contain application/json, and would thus add application/ld+json to the preferences. We would have to make sure this doens't override any of the other preferences, and make sure the original one is still preferred.

Specifically the case above could also be solved by making our media type matcher smarter so that it can detect that application/ld+json is an instance of application/json but this might not catch all cases. It would for example not be possible to detect that way that application/n-triples is a valid response when text/turtle has been requested.

Activity

  1. jvherweg commented on Oct 22, 2021

    @jvherweg
    MemberAuthor

    Another option would be to have the ContentTypeReplacer be part of the ChainedConverter inputs. But then some modifications would be needed so it is a TypedRepresentationConverter (or the interface there has to change).

  2. jvherweg commented on Nov 8, 2021

    @jvherweg
    MemberAuthor

    Done in #1030. Will be part of v3.0.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions