Mangling of headers in GRPC calls

I’ve followed the “Create Custom Authentication Plugin with NodeJS” guide from Here

One thing I’ve noticed that the headers are mangled in an awkward way.

For example is the following call was issued:
curl -H "Authorization: token" -H "GPRC-Authorization: token2" http://portal-instance2.com:8888/http-bin/get

From the GRPC handler, I am seeing the headers are mangled to capitalized kabab case instead of what was passed in via the headers.

{ hook_type: 'CustomKeyCheck',
  hook_name: 'MyAuthMiddleware',
  request:
   { headers:
      { Mycustomheader: 'mycustomvalue here!',
        'User-Agent': 'curl/7.54.0',
        Accept: '*/*',
        Authorization: 'token',
        'Gprc-Authorization': 'token2',
        Host: 'portal-instance2.com:8888' },

The above was logged from:

const authMiddleware = (obj, callback) => {
  var req = obj.request
  console.log(obj)
})

I am curious if there are ways to stop this behaviour or standardize the keys to all lower case, since header keys are case insensitive.

1 Like

Hi,

This will be down to how golang handles header prsing - it automatically turns all headers into capital case like this when it is parsing them.

The good news is that it is consistent, so you’ll always find headers will become Capitalise-Case no matter what you pass in.

1 Like