handling no content-type header returned by joernhees · Pull Request #498 · RDFLib/rdflib (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation8 Commits1 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

joernhees

@cliffxuan

@cliffxuan

the server doesn't necessarily have to return a content-type header, and you probably don't want to make this a show stopper?

The following is the http response for http://dev.w3.org/2000/10/swap/test/cwm/fam-rules.n3, and it doesn't have a content-type header.

HTTP/1.1 200 OK
Date: Mon, 20 Jul 2015 12:48:50 GMT
Server: Apache/2.2.22 (Debian)
Last-Modified: Fri, 30 Jan 2004 16:08:09 GMT
ETag: "122aa2-96-3d22471246c40"
Accept-Ranges: bytes
Content-Length: 150
Cache-Control: max-age=172800
Expires: Wed, 22 Jul 2015 12:48:50 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

@joernhees

it's correct that content-type isn't mandatory: http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1

the thing i'm not sure about is whether we should return None or '' or just raise an exception right here... what speaks against '' is the handling of content_type in Graph.parse(). If we return '' it won't enter the default handling of if format is None... but then the default handling would be wrong in this case and the comments there show that we should maybe be explicit and raise an exception.

So if at all, i'd rather return None:

     self.content_type = file.info().get('content-type')

@cliffxuan

@joernhees

True, but this would change our API semantics. We usually treat None as default (as in not specified) and '' as in argument was explicitly set to empty string. See the signature of Graph.parse(..., format=None, ...).

If a content-type is specified in HTTP it can't be an empty string, so i think it's worse to suddenly introduce a second undefined '' rather than just return None.

In favor of a smaller change i won't touch Graph.parse() for this... see #499

joernhees added a commit that referenced this pull request

Jul 20, 2015

@joernhees

fix handling URLInputSource without content-type, closes #498

@joernhees

still thanks for reporting this and sorry for opting another way ;)

@cliffxuan

that's ok. i don't mind too much, to be honest.

@cliffxuan

a side question, are you also the maintainer of Fuxi? what is the status of it? i created these fixes because i'm playing with the examples in Fuxi.

@joernhees

This was referenced

Jan 16, 2017

This was referenced

Mar 16, 2017

2 participants

@joernhees @cliffxuan