# HTTP Status Headers

**URL:** <https://www.ruby-forum.com/t/http-status-headers/212852>\
**Category:** NGINX\
**Created:** [October 15, 2011, 6:16pm UTC](https://www.ruby-forum.com/t/http-status-headers/212852 "2011-10-15T18:16:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [October 15, 2011, 6:16pm UTC](https://www.ruby-forum.com/t/http-status-headers/212852/1 "2011-10-15T18:16:00Z")

</div>

On 13 October 2011 04:34, agentzh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> BTW, you could have written the Lua code like this:
> 
> local m = ngx.re.match(ngx.var.request\_method, “GET|POST|HEAD”, “io”)  
> if not m then  
> ngx.exit(400)  
> end  
> Does ngx\_lua support the appropriate “501 Not Implemented” for this?  
> A search took me to ngx\_http\_lua\_consts.c but it doesn’t seem to be  
> there.

Also didn’t realise I could use the actual code instead of a constant.

Is it possible to issue any status code or are we limited to those in  
ngx\_http\_lua\_consts.c?

Cheers.

---

<div class="post-metadata">

**Author:** ![Nginx\_U](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dec6dc/32.png) [@Nginx\_U](https://www.ruby-forum.com/u/Nginx_U)\
**Post date:** [October 16, 2011, 1:03am UTC](https://www.ruby-forum.com/t/http-status-headers/212852/2 "2011-10-16T01:03:08Z")

</div>

On Sun, Oct 16, 2011 at 12:15 AM, Nginx U. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On 13 October 2011 04:34, agentzh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > BTW, you could have written the Lua code like this:
> > 
> > local m = ngx.re.match(ngx.var.request\_method, “GET|POST|HEAD”, “io”)  
> > if not m then  
> > ngx.exit(400)  
> > end  
> > Does ngx\_lua support the appropriate “501 Not Implemented” for this?

Sure. Just use ngx.exit(501) for it.

> A search took me to ngx\_http\_lua\_consts.c but it doesn’t seem to be there.

The constants defined there are just for improving Lua code readability.

> Also didn’t realise I could use the actual code instead of a constant.
> 
> Is it possible to issue any status code or are we limited to those in  
> ngx\_http\_lua\_consts.c?

You can use any status code. See

```
http://wiki.nginx.org/HttpLuaModule#ngx.exit

```

BTW, I’ve already added constant ngx.HTTP\_METHOD\_NOT\_IMPLEMENTED to  
ngx\_lua v0.3.1rc12:

```
https://github.com/chaoslawful/lua-nginx-module/tags

```

Regards,  
-agentzh

---

<div class="post-metadata">

**Author:** ![Nginx\_U](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/dec6dc/32.png) [@Nginx\_U](https://www.ruby-forum.com/u/Nginx_U)\
**Post date:** [October 16, 2011, 6:11am UTC](https://www.ruby-forum.com/t/http-status-headers/212852/3 "2011-10-16T06:11:41Z")

</div>

On 16 October 2011 02:02, agentzh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Sure. Just use ngx.exit(501) for it.
> 
> > 
> 
> You can use any status code. See
> 
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpLuaModule#ngx.exit)
> 
> BTW, I’ve already added constant ngx.HTTP\_METHOD\_NOT\_IMPLEMENTED to  
> ngx\_lua v0.3.1rc12:
> 
> [Tags · openresty/lua-nginx-module · GitHub](https://github.com/chaoslawful/lua-nginx-module/tags)

Cheers!
