From 621d70731566a6c7c11fc09a2bd4bbad4989fc88 Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Thu, 19 Nov 2020 15:04:57 +0000 Subject: [PATCH] fix: handles case where binary request does not return a response (#251) --- client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 9164f60..70b491d 100644 --- a/client.go +++ b/client.go @@ -341,11 +341,12 @@ type binaryResponse struct { func (c *Client) getBinary(ctx context.Context, config *apiConfig, apiReq apiRequest) (binaryResponse, error) { requestMetrics := c.metricReporter.NewRequest(config.path) httpResp, err := c.get(ctx, config, apiReq) - requestMetrics.EndRequest(ctx, err, httpResp, httpResp.Header.Get("x-goog-maps-metro-area")) if err != nil { + requestMetrics.EndRequest(ctx, err, httpResp, "") return binaryResponse{}, err } + requestMetrics.EndRequest(ctx, err, httpResp, httpResp.Header.Get("x-goog-maps-metro-area")) return binaryResponse{httpResp.StatusCode, httpResp.Header.Get("Content-Type"), httpResp.Body}, nil }