krakend / krakend-documentation

All the documentation under http://www.krakend.io/docs/
Apache License 2.0
24 stars 107 forks source link

Certain headers (Content-Type) have undocumented complications #224

Closed ethanpooley closed 2 months ago

ethanpooley commented 2 months ago

It appears that certain headers, including Content-Type, are subject to undocumented complications when one attempts to modify them. For example, the following backend configuration resulted in an empty Content-Type header being sent to the backend. Reversing the order of the two modifiers fixed this. My assumption is that attempts to alter the Content-Type header are tested for validity against the current body. So, the body must first be changed to something valid for the future Content-Type. This left me wondering if there are other such complications, and how users can discern them.

"extra_config": {
    "modifier/martian": {
        "fifo.Group": {
            "scope": ["request"],
            "modifiers": [
                {
                    "header.Modifier": {
                        "scope": [ "request" ],
                        "name": "Content-Type",
                        "value": "application/x-www-form-urlencoded"
                    }
                },
                {
                    "body.Modifier": {
                        "scope": [ "request" ],
                        "body": "c29tZXZhcj1zb21ldmFsJnNvbWVvdGhlcnZhcj1zb21lb3RoZXJ2YWw="
                    }
                }
            ]
        }
    }
}
kpacha commented 2 months ago

you are right, the content-type configuration value is not documented. see https://github.com/google/martian/blob/master/body/body_modifier.go#L46-L49

alombarte commented 2 months ago

Added to the documentation. Thanks for reporting!