Allow Non Canonical MIME Headers

Hi All,
I am calling an API via Tyk Gateway. This API has non canonical headers. What is happening is that Tyk Gateway is converting the headers into canonical headers which causes my API to call to fail as the headers are case sensitive. The API team has refused to change their policy regarding case sensitive headers, so we haveto ensure that the headers are unchanged by Tyk.
I have enable the “ignore_canonical_mime_header_key” but still I am facing the same problem.

Thanks for the help!!

Hi @MeetThink360,

Thank you for your question.

As stated in the docs

the ignore_canonical_mime_header_key variable is limited to JavaScript plugins, global header injection, virtual endpoint and JQ transform header rewrites.
This functionality doesn’t affect headers that are sent by the HTTP client and the default formatting will apply in this case.

You would need to leverage one of the options to achieve non-canonicality.

I think Global Header Injection would work just right. Used together with context variable to retrieve the value of the header.

  • Enable ignore_canonical_mime_header_key in the gateway config
  • Enable context variable in the API
  • Use Global Injection to (re)add the header in a case-sensitive manner
  • (Optional) Use Global Remove to remove the (original) canonicalized header

The API definition might look like this:

"version_data": {
  "versions": {
    "Default": {
    ...
    "global_headers": {
      "the-header": "$tyk_context.headers_The_Header"
    },
    "global_headers_remove": [
      "The-Header"
    ]
    ...
    }
  }
},
"enable_context_vars": true,

Doc References:
Context Variables
Global Header Injection and Removal

Hope this helps.

Thanks a lot !!! @Ubong. I was after this for a week. You really saved the day

1 Like