trifid
trifid copied to clipboard
Implement HEAD
There is currently no support for HTTP HEAD
. I think that would be nice to add, as it screwed myself several times when I did a curl
for head and didn't get the result I expected.
Quick fix: Return HTTP code 405
When I did this issue I was talking about checking if a resource exists, for example:
curl -I https://ld.admin.ch/canton/1
This currently returns a 404 even though it works just fine with a GET.
It should probably provide a result for all other resources as well with hard-configured routing, like /query
in case SPARQL is available.
Done here: https://github.com/zazuko/trifid-handler-sparql/commit/249be98cbe0b7a2e7408c2447fc9dba7a2e60a30
Example when calling an existing resource:
> curl -I https://lindas.zazukoians.org/canton/23
HTTP/2 200
date: Mon, 19 Dec 2022 17:16:49 GMT
content-type: text/plain; charset=utf-8
etag: W/"2-nOO9QiTIwXgNtWtBJezz8kv3SLc"
strict-transport-security: max-age=15724800
Example when calling a non-existing resource:
> curl -I https://lindas.zazukoians.org/canton/424242
HTTP/2 404
date: Mon, 19 Dec 2022 17:16:55 GMT
content-type: text/html; charset=utf-8
etag: W/"a-DBXRJ1WgvoTmQDRFxCcjHCdJGcY"
strict-transport-security: max-age=15724800
This should be the expected behavior now.
Looks good, I tested CORS as well:
curl --include \
--request GET \
--header 'Origin: http://example.com' \
https://lindas.zazukoians.org/canton/23
Returned headers look good:
HTTP/2 200
date: Wed, 04 Jan 2023 13:41:35 GMT
content-type: text/turtle
access-control-allow-origin: *
access-control-expose-headers: SD-Query-Id
cache-control: public, max-age=120
sd-query-id: 10007
set-cookie: i18n=en; Max-Age=2592000; Path=/; Expires=Fri, 03 Feb 2023 13:41:35 GMT
strict-transport-security: max-age=15724800
vary: Accept, Accept-Encoding