epugh opened a new pull request #495: URL: https://github.com/apache/solr/pull/495
https://issues.apache.org/jira/browse/SOLR-15116 # Description Handle a HEAD request by running the GET request and then dropping the body of the response. # Solution Turns out we were not supporting a HEAD request in the switch, so now we do. I got lucky that it appears in my manual testing that: ``` managedEndpoint.getSolrResponse().setHttpHeader("Content-Length", "0"); ``` deletes the response body as well as updating the header! # Tests Manual testing: Here is a GET: ``` solr-9.0.0-SNAPSHOT git:(main) ✗ curl -i "http://localhost:8983/solr/techproducts/schema/analysis/synonyms/english/foobar" HTTP/1.1 404 Not Found Content-Security-Policy: default-src 'none'; base-uri 'none'; connect-src 'self'; form-action 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self' data:; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; worker-src 'self'; X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Cache-Control: no-cache, no-store Pragma: no-cache Expires: Sat, 01 Jan 2000 01:00:00 GMT Last-Modified: Tue, 04 Jan 2022 21:46:57 GMT ETag: "17e270f3e4a" Content-Type: application/json;charset=utf-8 Content-Length: 535 { "responseHeader":{ "status":404, "QTime":1}, "error":{ "metadata":[ "error-class","org.apache.solr.common.SolrException", "root-error-class","org.apache.solr.common.SolrException"], "msg":"foobar not found in /schema/analysis/synonyms/english", "code":404}, "error":{ "metadata":[ "error-class","org.apache.solr.common.SolrException", "root-error-class","org.apache.solr.common.SolrException"], "msg":"foobar not found in /schema/analysis/synonyms/english", "code":404}} ``` And here is a HEAD, notice the 404 instead of the old 200: ``` ➜ solr-9.0.0-SNAPSHOT git:(main) ✗ curl -I "http://localhost:8983/solr/techproducts/schema/analysis/synonyms/english/foobar" HTTP/1.1 404 Not Found Content-Security-Policy: default-src 'none'; base-uri 'none'; connect-src 'self'; form-action 'self'; font-src 'self'; frame-ancestors 'none'; img-src 'self' data:; media-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; worker-src 'self'; X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Cache-Control: no-cache, no-store Pragma: no-cache Expires: Sat, 01 Jan 2000 01:00:00 GMT Last-Modified: Tue, 04 Jan 2022 21:46:05 GMT ETag: "17e270e720f" Content-Type: application/json;charset=utf-8 Content-Length: 0 ``` # Checklist Please review the following and check all that apply: - [X ] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability. - [ X] I have created a Jira issue and added the issue ID to my pull request title. - [ X] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended) - [ X] I have developed this patch against the `main` branch. - [ ] I have run `./gradlew check`. - [ ] I have added tests for my changes. - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
