Skip to content

Return correct Content-Type for JSON-LD resources (from file extension) #413

Closed

Description

@csarven

If Content-Type is derived from the file extension, return the correct mime-type in the response headers. Appears to default to text/turtle.

e.g.,

  • foo.jsonld returns text/turtle Content-Type
  • foo.json returns application/json with HTTP 501 (this is probably a separate issue)

Possibly related:

  • foo (in JSON-LD) returns text/turtle Content-Type
  • "Accept: application/ld+json" returns Error translating between RDF formats (trying to parse it as Turtle before trying serialise as JSON-LD - see also Fix serialization to jsonld #226)

Activity

  1. dmitrizagidulin commented on Jul 5, 2016

    @dmitrizagidulin
    Contributor

    I suspect that whatever library we're using to derive content type from file extensions doesn't recognize .jsonld.. We should look into it (and if there's nothing to be done there, handle it separately in the code).

  2. changed the title [-]Return correct Content-Type for resource with extension[/-] [+]Return correct Content-Type for JSON-LD resources (from file extension)[/+] on Jul 6, 2016
  3. dmitrizagidulin commented on Jul 19, 2016

    @dmitrizagidulin
    Contributor

    Let's tackle these issues one at a time.

    foo.jsonld should return application/ld+json as its Content-Type

    The main culprit is that the mime npm package that node-solid-server is using to translate from a file extension to a MIME Type just doesn't recognize application/ld+json as a valid type. Try this out in your terminal:

    npm install mime
    node
    > var mime = require('mime')
    > mime.extension('application/json')
    'json'
    > mime.extension('application/ld+json')
    undefined

    Same thing in the other direction:

    > mime.lookup('.json')
    'application/json'
    > mime.lookup('.jsonld')
    'application/octet-stream'

    I suspect this is because the JSON-LD MIME Type is still undergoing the IANA standardization process? I think a temporary fix for this might be adding in a hardcoded custom check to node-solid-server, to test specifically for the .jsonld extension.

  4. csarven commented on Jul 20, 2016

    @csarven
    MemberAuthor
  5. dmitrizagidulin commented on Jul 20, 2016

    @dmitrizagidulin
    Contributor

    @csarven aha! Excellent. Let's file an issue on the mime npm package, to add it?

  6. dmitrizagidulin commented on Jul 21, 2016

    @dmitrizagidulin
    Contributor

    Can somebody open an issue on mime-db, or make a PR for jsonld?

  7. melvincarvalho commented on Jul 21, 2016

    @melvincarvalho
    Contributor

    JSON-LD is supported by mime-db, isnt it? What would the pull request be for?

  8. dmitrizagidulin commented on Jul 21, 2016

    @dmitrizagidulin
    Contributor

    @melvincarvalho oh, whoops, yeah. I was hoping the mime npm package drew from that, but looks like it doesnt.

  9. dmitrizagidulin commented on Nov 22, 2016

    @dmitrizagidulin
    Contributor

    This has been fixed in PR #430. Closing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions