CORS is the Cross-Origin-Resource-Sharing mechanism explained at
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS 1. by default
JavaScript code from Website A cannot request arbitrary resources from
website B, these are called cross-origin-requests 2. The browser
performs what is called a preflight check, this the OPTIONS method 3.
the response allows website B fine-grained control over what the web
browser should allow 4. Setting "Access-Control-Allow-Origin: *" tells
the web browser to allow all access, e.g. the same behavior you get with
curl or debuginfod-find The website mentions that the corresponding spec
has been changed, such that preflight requests are no longer necessary,
but in the browsers I use today (Firefox 132 and Chromium 131) they are
still necessary.
I have confirmed that I can use debuginfod with this patch from my web
application at https://core-explorer.github.io/cdx-type/
FChE simplified the code and added a few quick "curl -i | grep" tests
to confirm the new headers are there.
* debuginfod/debuginfod.cxx (handle_options): New function.
(handler_cb): Call it for OPTIONS. Add ACAO header for all
successful requests.
(parse_opt): Parse --cors.
* tests/run-debuginfod-federation-metrics.sh,
tests/run-debuginfod-find-metadata.sh: Lightly test.
* doc/debuginfod.8: Document --cors option, default off.
Signed-off-by: Henning Meyer <hmeyer.eu@gmail.com> Signed-off-by: Frank Ch. Eigler <fche@redhat.com>