Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can 'sent' HTTP variables work? #118

Open
larry-cdn77 opened this issue Mar 3, 2021 · 1 comment
Open

Can 'sent' HTTP variables work? #118

larry-cdn77 opened this issue Mar 3, 2021 · 1 comment

Comments

@larry-cdn77
Copy link

larry-cdn77 commented Mar 3, 2021

I configured:

more_set_headers 'X-Magic: $sent_http_x_slytherin';

Did I understand it correctly that due to module initialisation order, headers-more is executed before the standard headers filter where X-Slytherin is set? Consequently, headers-more will not see X-Slytherin when setting X-Magic.

In other words, the HTTP 'sent' variables as implemented in ngx_http_variable_unknown_header are one of the products of header filters downstream of the headers-more filter that do not yet exist at the time of expanding variables in headers-more.

If I got this right, am I also right that such scenario is an example of undefined behaviour @agentzh referred to in his OpenResty notes when he wrote the below?

Out of sheer curiosity, we shall ask immediately that what would be execution ordering in between more_set_input_headers and rewrite_by_lua, since they both ride on rewrite tail? The answer is : undefined. We must avoid a configuration which relies on their execution orders.

@larry-cdn77
Copy link
Author

A suitable workaround might be:

more_clear_headers X-Magic;
add_header X-Magic $sent_http_x_slytherin;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant