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

MeSH SPARQL endpoint does not seem to return HTTP Content-Type header #149

Open
yayamamo opened this issue Nov 18, 2020 · 4 comments
Open

Comments

@yayamamo
Copy link

When issuing a SPARQL query to the endpoint by a curl tool, I've noticed that the response header didn't include an HTTP Content-Type header.
This may cause inappropriate behavior of a SPARQL client.

Below is the one I encountered. The query is a Construct SPARQL query.

% curl -vLH 'Accept: application/rdf+xml' --data-urlencode query@query.rq https://id.nlm.nih.gov/mesh/sparql 
...
> POST /mesh/sparql HTTP/1.1
> Host: id.nlm.nih.gov
> User-Agent: curl/7.64.1
> Accept: application/rdf+xml
> Content-Length: 365
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 365 out of 365 bytes
< HTTP/1.1 200 
< Date: Wed, 18 Nov 2020 05:05:07 GMT
< Server: Apache/2.4.6 (CentOS)
< X-Frame-Options: SAMEORIGIN
< X-Forwarded-Proto: https
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, PUT
< Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With
< Access-Control-Max-Age: 1800
< Set-Cookie: JSESSIONID=4D5D6794B67A0483E64DC70F07CFDFF2; Path=/mesh; Secure; HttpOnly
< Cache-Control: no-cache,no-store
< X-XSS-Protection: 1; mode=lock
< Transfer-Encoding: chunked
< X-count: 2
< X-VIP-Info: 130.14.16.63:443
< X-Pool-Info: /Common/id_pool 10.1.5.126 80
< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< 
...

In addition, when trying a query at MeSH RDF API, I noticed that there was mismatch between Response content type and the one in the Response headers.
I set it to application/ld+json, but the response was content-type: application/rdf+xml;charset=utf-8.
Moreover, text/turtle and application/rdf+n3 also set no content-type as in the case of application/rdf+xml.

@danizen
Copy link
Contributor

danizen commented Nov 18, 2020

Thank you; these are errors that may be upstream in Lodestar, or at least in the version of Lodestar upon which we base MeSH RDF. I will follow-up shortly, at least by the time we have updated MeSH RDF so that 2021 is current and no longer interim.

@danizen
Copy link
Contributor

danizen commented Nov 29, 2021

I wonder whether your Accept request header matches the SPARQL query. When I do a simple SELECT query I get Content-Type application/sparql-results+xml;charset=utf-8 as the response. If I then manually set the Accept request header to application/rdf+xml, then the Content-Type is missing on the response.

The content type returned is conceptually able to specified by the Accept request header (e.g. should support Content-Negotiation). In practice you have to be careful to match the Content-Type to what is returned via the Query Editor as you select the various formats.

If that explains the what you experienced, let me know and I will close this Github issue.

@yayamamo
Copy link
Author

What I got was a SPARQL CONSTRUCT query response without an HTTP Content-Type header, which should be RDF, and therefore application/rdf+xml was a valid response of Content-Type.
( https://www.w3.org/TR/sparql11-protocol/#construct-simple )
For example, the response to the query CONSTRUCT WHERE { <http://id.nlm.nih.gov/mesh/C000612320> ?pred ?obj . } should have an HTTP Content-Type header of Content-Type: application/rdf+xml when its HTTP Accept request header is Accept: application/rdf+xml.
This issue (i.e., no Content-Type header in a response) happens in the case of Accept: text/turtle, too.
However, that response header IS included when I set the Accept request header of Accept: text/html or Accept: text/plain, whose headers of response are Content-Type: application/rdf+xml;charset=utf-8 and Content-Type: text/plain;charset=utf-8, respectively.

@danizen
Copy link
Contributor

danizen commented Nov 30, 2021

Thanks, I'll look into that.

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

2 participants