Unable to assign error message on failed HEAD request

In one of our API proxies, we have AssignMessage policy that sets up Error content describing the cause for the error whenever VerifyAPIKey policy fails.

If we make a GET request for this API, then we get the following error message

{"errors":{"api_key":["is missing"]},"data":{},"meta":{"deprecation_information":{},"api_version":"1.2"}}

However, if we make a HEAD request and if it fails, then we just the get the HTTP Error code. But, we don't get the error message.

Is this expected behaviour or a bug ?

Solved Solved
0 2 621
1 ACCEPTED SOLUTION

Not applicable

@AMAR DEVEGOWDA As per HTTP spec, the response for an HEAD request should contain only the content-length of the response body and content should be empty. In edge gateway, the payload will be suppressed in the HTTP response. Receiving an empty response for an HEAD request is the expected behaviour.

View solution in original post

2 REPLIES 2

Not applicable

@AMAR DEVEGOWDA As per HTTP spec, the response for an HEAD request should contain only the content-length of the response body and content should be empty. In edge gateway, the payload will be suppressed in the HTTP response. Receiving an empty response for an HEAD request is the expected behaviour.

@tskumar@apigee.com,

Thanks for your response.

As per HTTP spec, for an HEAD request it says this:

9.4 HEAD

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

So, the response content will not be set/sent irrespective of whether it's a successful/error response from the target server or some policy within the API Proxy fails with an error.