add nil pointer guard to resp.Headers in middleware (#3393)

#### Does this PR need a docs update or release note?

- [x]  No

#### Type of change

- [x] 🐛 Bugfix

#### Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2023-05-11 10:38:13 -06:00 committed by GitHub
parent 245d3ee089
commit 0202207f3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -506,6 +506,11 @@ func (mw *MetricsMiddleware) Intercept(
// track the graph "resource cost" for each call (if not provided, assume 1)
// nil-pointer guard
if len(resp.Header) == 0 {
resp.Header = http.Header{}
}
// from msoft throttling documentation:
// x-ms-resource-unit - Indicates the resource unit used for this request. Values are positive integer
xmru := resp.Header.Get(xmruHeader)