grpc-ecosystem/grpc-gateway

Unsupported HEAD call to known URL does not return error response body.

Open

#1,680 opened on Sep 21, 2020

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Go (16,971 stars) (2,250 forks)batch import
bughelp wanted

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

  1. Define a gRPC endpoint with only a GET-http-mapping (or any other method).
  2. Generate and start the grpc-gateway
  3. Perform a http HEAD-call to the same URL.
  4. 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

Contributor guide