-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pdk):
service.response.get_headers
behavior
This commit attempts to fix several issues in the `kong.service.response.get_headers()` module: 1. Said method must only return response headers set by the upstream service. However, since its introcution, it is broken; in the original implementation, it added an `__index` metamethod to the full headers table (both Kong and upstream headers) to ensure a given header being indexed was found in a `ngx.var.upstream_http_<header_name> variable (ie, it was set by the upstream). However, it responded with the table itself, which contained the headers, so the `__index` metamethod would never be called. 2. Buffered proxying, later added, introduced new logic to handle buffered headers. This logic corretly implemented the metamethod by using a so-called "proxy table"; this is an empty table to which the `__index` metamethod is added. Since it's empty, `__index` is correctly invoked and ensures only upstream headers are accessible (as described by 1.). However, being empty it does not allow the headers table to be iterated on, leading to inconsistent and unexpected behavior -- a source of bug reports (e.g., #11546, KAG-4866, to name two).
- Loading branch information
Showing
2 changed files
with
390 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.