Giving the conf below, I would expect to find the value of the "If-Match" header if supplied. However, that is not the case (see below)Nginx.conf:-----events { worker_connections 19000; multi_accept on;}http { server { listen 80; location / { content_by_lua ' ngx.say(ngx.req.get_headers()["If-Match"]) '; } } }-----Result:I'm using the Chrome app, Postman, as the client. When I don't supply a header, it outputs "Nil" as expected. If I supply an "If-Match" header with any value, I get the following response:-----<html> <head> <title>412 Precondition Failed</title> </head> <body bgcolor="white"> <center> <h1>412 Precondition Failed</h1> </center> <hr> <center>openresty/1.9.7.4</center> </body></html>----- .
This seems to be expected behavior, based on the presence of that header. This is a function of Nginx processing the request, not how the Lua code handles the header. See http://odino.org/don-t-hurt-http-if-none-match-the-412-http-status-code/ for more info.On Wed, May 25, 2016 at 10:39 AM, JB <jboy...@gmail.com> wrote:Giving the conf below, I would expect to find the value of the "If-Match" header if supplied. However, that is not the case (see below)Nginx.conf:-----events { worker_connections 19000; multi_accept on;}http { server { listen 80; location / { content_by_lua ' ngx.say(ngx.req.get_headers()["If-Match"]) '; } } }-----Result:I'm using the Chrome app, Postman, as the client. When I don't supply a header, it outputs "Nil" as expected. If I supply an "If-Match" header with any value, I get the following response:-----<html> <head> <title>412 Precondition Failed</title> </head> <body bgcolor="white"> <center> <h1>412 Precondition Failed</h1> </center> <hr> <center>openresty/1.9.7.4</center> </body></html>----- .
I understand that it is the expected behavior, but is there any way to override it?On Wednesday, May 25, 2016 at 2:36:26 PM UTC-4, rpaprocki wrote:This seems to be expected behavior, based on the presence of that header. This is a function of Nginx processing the request, not how the Lua code handles the header. See http://odino.org/don-t-hurt-http-if-none-match-the-412-http-status-code/ for more info.On Wed, May 25, 2016 at 10:39 AM, JB <jboy...@gmail.com> wrote:Giving the conf below, I would expect to find the value of the "If-Match" header if supplied. However, that is not the case (see below)Nginx.conf:-----events { worker_connections 19000; multi_accept on;}http { server { listen 80; location / { content_by_lua ' ngx.say(ngx.req.get_headers()["If-Match"]) '; } } }-----Result:I'm using the Chrome app, Postman, as the client. When I don't supply a header, it outputs "Nil" as expected. If I supply an "If-Match" header with any value, I get the following response:-----<html> <head> <title>412 Precondition Failed</title> </head> <body bgcolor="white"> <center> <h1>412 Precondition Failed</h1> </center> <hr> <center>openresty/1.9.7.4</center> </body></html>----- .
Maybe a better understanding of what you're trying to accomplish would help. As far as overriding Nginx's handling, I doubt it, because you'd be violating the HTTP spec.On Thu, May 26, 2016 at 8:34 AM, JB <jboy...@gmail.com> wrote:I understand that it is the expected behavior, but is there any way to override it?On Wednesday, May 25, 2016 at 2:36:26 PM UTC-4, rpaprocki wrote:This seems to be expected behavior, based on the presence of that header. This is a function of Nginx processing the request, not how the Lua code handles the header. See http://odino.org/don-t-hurt-http-if-none-match-the-412-http-status-code/ for more info.On Wed, May 25, 2016 at 10:39 AM, JB <jboy...@gmail.com> wrote:Giving the conf below, I would expect to find the value of the "If-Match" header if supplied. However, that is not the case (see below)Nginx.conf:-----events { worker_connections 19000; multi_accept on;}http { server { listen 80; location / { content_by_lua ' ngx.say(ngx.req.get_headers()["If-Match"]) '; } } }-----Result:I'm using the Chrome app, Postman, as the client. When I don't supply a header, it outputs "Nil" as expected. If I supply an "If-Match" header with any value, I get the following response:-----<html> <head> <title>412 Precondition Failed</title> </head> <body bgcolor="white"> <center> <h1>412 Precondition Failed</h1> </center> <hr> <center>openresty/1.9.7.4</center> </body></html>----- .
Hello! On Thu, May 26, 2016 at 8:50 AM, JB wrote: > The end result is a sort of proxy through Lua code. Agreed that it would be > violating the HTTP spec, but for whatever reason this is what the end user > wants. Is there any way to do it? > Yes, you can use ngx.req.clear_header() to clear that offending request header in Lua: https://github.com/openresty/lua-nginx-module#ngxreqclear_header Regards, -agentzh