You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this only adds two tests that fail, but I'd like some input as to whether it is a reasonable expectation of an LDP implementation that they would pass.
They beg the question of whether an LDP server should remember the Content-Type of resources that are added to it.
5.2.3.6 LDP servers should use the Content-Type request header to determine the request representation's format when the request has an entity body.
The two tests are the same, but one each for 'text/plain' and 'application/json' resources. They
Create a resource with that Content-Type (via PUT)
Try to GET it with 'Accept: {contentType}'
Assert that the response to the GET has 'Content-Type: {contentType}', which fails. Currently the Content-Type response header is 'application/octet-stream; charset=utf-8' (generic), unless the resource path ends in '.json', in which case it's JSON
If these are tests that should pass, then it seems that one way of implementing this would be to automatically create a resource-name.meta resource when resource-name is created/updated (e.g. via PUT). If resource-name is PUT with Content-Type: text/plain, then this also creates resource-name.meta with some body that indicates that the canonical content type of resource-name is text/plain. Then, when someone does GET resource-name with a certain Accept header, ldnode can know whether it can respond with the resource in that Content Type.
Right now resource-name and resource-name.meta files appear to be implicitly used together, but keeping them 'in sync' is expected to be done by the client the api. So this sort of consistency enforcement could, I guess, just be done by a proxy that sits in front of a 'dumb' ldnode.
So the two questions
Should these tests pass in an ideal implementation of LFDP?
If yes, what's the best way to implement it in ldnode?
This not expected behaviour, you are right.
Thanks for your tests, they have been very helpful to understand the problem.
As far as I understand ldnode uses mime which is a library that will guess the mime type by looking at the file extension. Since you are not specifying the file extension, this would fail to guess and would fallback to the default application/octet-stream.
So, this clearly is a bug - there are two way of solving this:
Sniffing the content and use clever sniffing which we would like to avoid
Follow what Gold (I ping @deiu here) does, which is basically storing the file that you store with PUT with the content type, with a special name resource-name$mime.extension(req.headers['content-type']) and remove the $ when serving the file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently this only adds two tests that fail, but I'd like some input as to whether it is a reasonable expectation of an LDP implementation that they would pass.
They beg the question of whether an LDP server should remember the Content-Type of resources that are added to it.
From http://www.w3.org/TR/ldp/#ldpc-container :
The two tests are the same, but one each for 'text/plain' and 'application/json' resources. They
If these are tests that should pass, then it seems that one way of implementing this would be to automatically create a
resource-name.metaresource whenresource-nameis created/updated (e.g. via PUT). Ifresource-nameis PUT withContent-Type: text/plain, then this also createsresource-name.metawith some body that indicates that the canonical content type ofresource-nameistext/plain. Then, when someone does GETresource-namewith a certainAcceptheader, ldnode can know whether it can respond with the resource in that Content Type.Right now
resource-nameandresource-name.metafiles appear to be implicitly used together, but keeping them 'in sync' is expected to be done by the client the api. So this sort of consistency enforcement could, I guess, just be done by a proxy that sits in front of a 'dumb' ldnode.So the two questions