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
ngx.exit(ngx.HTTP_NOT_FOUND) still returns 200 #15
Comments
Hello! On Mon, Mar 11, 2013 at 12:44 AM, Anthony Scalisi
Tested on my side:
Looking good, huh?
Regards, |
Thanks for the reply @agentzh. I'm still getting a 200 OK on a key not found in Redis (based on Please have a look at this snippet, this is the full code: https://gist.github.com/scalp42/5137764 I'm making sure to strip the leading You can test in Redis using:
And then using curl:
Thanks a lot in advance! |
I just figured it out based on your comments. I indeed call UPDATED: still getting 200 OK for some reason even removing that top I see the problem in
but I removed any |
I figured it out even though it's not clear to me: 200 OK:
404:
I'm confused regarding ngx.exit. Per the doc http://wiki.nginx.org/HttpLuaModule#ngx.exit :
It looks like
|
Hello! By default, ngx_lua output response data in a non-buffered manner (in When you call ngx.say() for the first time, the response header will Consider the following minimal example:
Accessing /t will yield
Why 200? Because the response header with 200 (the default status You can change the status code by setting ngx.status before sending
This is documented in the manual for ngx.say and ngx.print:
To quote: "emits arguments concatenated to the HTTP client (as Regards, |
Hello! On Mon, Mar 11, 2013 at 3:39 PM, agentzh agentzh@gmail.com wrote:
Also, if you check out your nginx's error.log file (please always do
sending out the response status 200 So your ngx.exit() call just complaints about the fact that a response Regards, |
Thanks for the precisions @agentzh, much appreciated. 👍 |
the same situation happenes to me ,this is a strange thing~ |
@HoldSoulSkip You must have sent out the request header earlier (maybe implicitly by calling |
@agentzh Thank you very much |
You should set response status before "say"
|
Hi Yichun,
Thanks a lot for all those modules !
I tried to run your example and can't figure how to actually returns a 404 if the key is not found (hence
res == null
inlocal res, err = red:get(ngx.var.key_that_does_not_exist)
.Snippet:
Also tried:
Output:
Any idea by any chance ?
The text was updated successfully, but these errors were encountered: