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

Handle Content-Type parameter #1648

Open
csarven opened this issue Dec 29, 2021 · 9 comments
Open

Handle Content-Type parameter #1648

csarven opened this issue Dec 29, 2021 · 9 comments

Comments

@csarven
Copy link
Member

csarven commented Dec 29, 2021

@kjetilk
Copy link
Member

kjetilk commented Dec 29, 2021

Ah, the error message confused me also, my interpretation of that is that the message body has invalid text/turtle, but what this actually should say is that "Only text/turtle is supported for RDF" or something like that.

In the case above, the message body was empty, so it was certainly possible.

@bourgeoa right, but it doesn't appear that that function is actually used by the handler. So that seems to be the problem indeed.

@csarven csarven changed the title Handle request Content-Type charset Handle Content-Type parameter Dec 29, 2021
@csarven
Copy link
Member Author

csarven commented Dec 29, 2021

getContentType shouldn't remove parameter. If the intention is to get only the type/subtype, then another function name may be more clear.

@csarven
Copy link
Member Author

csarven commented Dec 29, 2021

@kjetilk "Only text/turtle is supported for RDF" wouldn't be accurate either because as it stands, NSS's rejection of the request may be due to the fact that the media-type value includes a parameter (eg. charset).

I think the server should accept Content-Type with parameters. If the server wants to process the message body in context of the parameter, it can do that separately.

@bourgeoa
Copy link
Member

getContentType shouldn't remove parameter. If the intention is to get only the type/subtype, then another function name may be more clear.

It can be changed. Have you a better proposal ?

@kjetilk
Copy link
Member

kjetilk commented Dec 29, 2021

@csarven: yeah, but the intention of that if is to check for actual media type, and then it would be more clear.

@bourgeoa: I would return an object, where the media type is one property and parameters are other properties, but that wouldn't be backwards compatible I guess. Perhaps it could return an array where the first element is the media type and then parameters as other elements in the array?

@bourgeoa
Copy link
Member

@kjetilk NSS is a filesystem implementation, with contentType stored in filename extension as mimeType.
Are there any use of parameters that are not stored ?
I suppose that is why the function was created like that.

@kjetilk
Copy link
Member

kjetilk commented Dec 29, 2021

@kjetilk NSS is a filesystem implementation, with contentType stored in filename extension as mimeType. Are there any use of parameters that are not stored ? I suppose that is why the function was created like that.

I suppose that NSS would like to make sure that everything it stores is UTF-8. Turtle is a special case, since it is required to be UTF-8 by its spec, but thinking generally, I would think that the server might want to re-encode a body before to UTF-8 if it isn't coming in as UTF-8.

@kjetilk
Copy link
Member

kjetilk commented Dec 29, 2021

I just had a look over the specs again. Turtle says:

The media type of Turtle is text/turtle. The content encoding of Turtle content is always UTF-8. Charset parameters on the mime type are required until such time as the text/ media type tree permits UTF-8 to be sent without a charset parameter.

The problem that I think that this was intended to address was that RFC2046 required the default charset for any text/ media type to be US-ASCII (oh, the horror!). Then, RFC6657 came along to say that:

Each subtype of the "text" media type that uses the "charset" parameter can define its own default value for the "charset" parameter, including the absence of any default.

which Turtle does. So, it seems that it is now legitimate for a client to skip sending the charset parameter, but RFC6657 was published before the Turtle Recommendation, so I'm not quite sure why they formulated it like that, perhaps to satisfy the SHOULD further down in the RFC.

So, in conclusion, it is really important that NSS doesn't reject a request with a query parameter. It is currently not so important to record the charset parameter, but it should do so to ensure that all files are written with UTF-8 in case a client specifies something else.

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

No branches or pull requests

3 participants