kong
kong copied to clipboard
fix(http-log) properly migrate headers when multiple values are provided
In Kong <=2.8, the http-log plugin supports providing multiple header values in the array, and will automatically concatenate them (delimited by , ) when sent over the wire to the defined HTTP log endpoint.
Prior to these code changes, if someone has {"some-header": ["test1", "test2"]} set as the headers on their plugin config, when migrating from 2.8 to 3.0, it’d re-write the headers config to {"some-header": "test1"}. These code changes allow to retain the same behavior as prior versions.
Given the example headers config above, the headers sent by the gateway in a manual integration test are below:
Content-Length: 1556
User-Agent: lua-resty-http/0.16.1 (Lua) ngx_lua/10020
Content-Type: application/json
some-header: test1, test2
The DB migration was manually tested from 2.8 -> 3.0. Below is the state of the plugin in 2.8 (before the migration) and in 3.0 (after the migration):
// One header defined with two values.
//
// v2.8 plugin config:
{
"method": "POST",
"headers": {
"some-header": [
"test1",
"test2"
]
},
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// v3.0 plugin config:
{
"method": "POST",
"headers": {
"some-header": "test1, test2"
},
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// One header defined with one value.
//
// v2.8 plugin config:
{
"method": "POST",
"headers": {
"some-header": [
"test1"
]
},
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// v3.0 plugin config:
{
"method": "POST",
"headers": {
"some-header": "test1"
},
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// One header defined with no value.
//
// v2.8 plugin config:
{
"method": "POST",
"headers": {
"some-header": {}
},
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// v3.0 plugin config:
{
"method": "POST",
"headers": null,
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// One header defined with one value, another with no value.
//
// v2.8 plugin config:
{
"method": "POST",
"headers": {
"some-header": {},
"another-header": [
"test1"
]
},
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// v3.0 plugin config:
{
"method": "POST",
"headers": {
"another-header": "test1"
},
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// No headers defined.
//
// v2.8 plugin config:
{
"method": "POST",
"headers": null,
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
// v3.0 plugin config:
{
"method": "POST",
"headers": null,
"timeout": 10000,
"keepalive": 60000,
"queue_size": 1,
"retry_count": 10,
"content_type": "application/json",
"flush_timeout": 2,
"http_endpoint": "http://127.0.0.1:8081",
"custom_fields_by_lua": null
}
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.