-
Notifications
You must be signed in to change notification settings - Fork 7
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
Check MIME-Type before parsing body content #37
Comments
This should totally be fixed by Stardog too xd |
Not sure what the conclusion is so far. I think we can agree that 200 is not very helpful in this case, the question is should there be a way to have an override of an error-handler so we can catch particularities like what Stardog is doing? @mielvds if I get you correctly you cannot get the JSON returned from Stardog at the moment? At least not in a parsable way |
The error I had turned out unrelated, so I removed the comments. |
@tpluscode do you have a proposal for what I should report @ Stardog? |
We already have, haven't we? Regardless of this particular scenario, it is possible that the body is ini whatever way malformed and would fail to parse. Is it so that parser errors are not handled gracefully? |
Problem:
checkResponse(res) is checking for HTTP Status Code 200 OK. This is not enough. Stardog is answering with Status Code OK on failure but the content is JSON with an Error description.
In the code ... https://github.com/zazuko/sparql-http-client/blob/b8575ba15260ff3f038326bc757c3bf9f6dff10b/StreamQuery.js#L56
we check
checkResponse(res)
for HTTP 200 and then the body is parsed with N3Parser.Because Stardog is sending HTTP 200 on error
parser.import(res.body)
tries to parse a JSON body. This leads to a parsing error.To avoid this we should check if the content type is
application/n-triples
ortext/turtle
before parsing it.The text was updated successfully, but these errors were encountered: