Unsupported HEAD call to known URL does not return error response body.
#1,680 opened on Sep 21, 2020
Description
🐛 Bug Report
When performing a HTTP call using an unsupported method, for example when making a POST request to a URL that only supports GET, I get a http-501-error-response from the gateway. The response body contains the grpc error code 12 ("Unimplemented") with the message "Method Not Allowed".
When performing a HEAD-call to the same get-only-URL, I expect the same error response. What happens is that the http request fails with 501 (which is correct), but the response body stays empty. According to the documentation, the HEAD call should not have any special behaviour, so I expect the body to contain the same error details. An error-response-body should never be empty. Docs: https://cloud.google.com/service-infrastructure/docs/service-management/reference/rpc/google.api#special-notes
To Reproduce
- Define a gRPC endpoint with only a GET-http-mapping (or any other method).
- Generate and start the grpc-gateway
- Perform a http HEAD-call to the same URL.
- The response (status 501) will have an empty body.
Your Environment
Im using github.com/grpc-ecosystem/grpc-gateway/v2 v2.0.0-beta.4