How to return a comma in a header using DownstreamHeaderTransform
json-option?
#2249
-
I would like to return the following header using DownstreamHeaderTransform: So I added the following code to my route: "DownstreamHeaderTransform": {
"Cache-Control": "public, max-age=1800"
}, However, the comma is used to replace values, so it doesn't work: Find and Replace Is there any way to escape it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Try to encode the header value by online tool: https://www.urlencoder.io/ {
"DownstreamHeaderTransform": {
"Cache-Control": "public%2C max-age=1800"
},
// ..
} I believe the browsers should understand it. |
Beta Was this translation helpful? Give feedback.
-
What I wonder is Why do you transform downstream response headers including |
Beta Was this translation helpful? Give feedback.
The comma is hard-coded as a delimiter in the HeaderFindAndReplaceCreator class, lines below 47:
Ocelot/src/Ocelot/Configuration/Creator/HeaderFindAndReplaceCreator.cs
Lines 47 to 49 in d1ecfaf
Ocelot has no options to specify custom delimiter. It needs to be developed. No such sub-feature.
To implement this solution using C#, you need to:
PreErrorResponderMiddleware
using the Middleware Injection feature. In the response, locate theCache-Control
header with an invalid value and correct it."Cache-Control": "public%2C max-age=1…