Skip to content

Commit c3ac14e

Browse files
committed
feature: added many more HTTP status constants as ngx.HTTP_XXX. thanks Vadim A. Misbakh-Soloviov for the patch in openresty#425.
1 parent f48aef5 commit c3ac14e

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

README.markdown

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2963,23 +2963,40 @@ HTTP status constants
29632963

29642964
```nginx
29652965
2966+
value = ngx.HTTP_CONTINUE (100) (first added in the v0.9.20 release)
2967+
value = ngx.HTTP_SWITCHING_PROTOCOLS (101) (first added in the v0.9.20 release)
29662968
value = ngx.HTTP_OK (200)
29672969
value = ngx.HTTP_CREATED (201)
2970+
value = ngx.HTTP_ACCEPTED (202) (first added in the v0.9.20 release)
2971+
value = ngx.HTTP_NO_CONTENT (204) (first added in the v0.9.20 release)
2972+
value = ngx.HTTP_PARTIAL_CONTENT (206) (first added in the v0.9.20 release)
29682973
value = ngx.HTTP_SPECIAL_RESPONSE (300)
29692974
value = ngx.HTTP_MOVED_PERMANENTLY (301)
29702975
value = ngx.HTTP_MOVED_TEMPORARILY (302)
29712976
value = ngx.HTTP_SEE_OTHER (303)
29722977
value = ngx.HTTP_NOT_MODIFIED (304)
2978+
value = ngx.HTTP_TEMPORARY_REDIRECT (307) (first added in the v0.9.20 release)
29732979
value = ngx.HTTP_BAD_REQUEST (400)
29742980
value = ngx.HTTP_UNAUTHORIZED (401)
2981+
value = ngx.HTTP_PAYMENT_REQUIRED (402) (first added in the v0.9.20 release)
29752982
value = ngx.HTTP_FORBIDDEN (403)
29762983
value = ngx.HTTP_NOT_FOUND (404)
29772984
value = ngx.HTTP_NOT_ALLOWED (405)
2985+
value = ngx.HTTP_NOT_ACCEPTABLE (406) (first added in the v0.9.20 release)
2986+
value = ngx.HTTP_REQUEST_TIMEOUT (408) (first added in the v0.9.20 release)
2987+
value = ngx.HTTP_CONFLICT (409) (first added in the v0.9.20 release)
29782988
value = ngx.HTTP_GONE (410)
2989+
value = ngx.HTTP_UPGRADE_REQUIRED (426) (first added in the v0.9.20 release)
2990+
value = ngx.HTTP_TOO_MANY_REQUESTS (429) (first added in the v0.9.20 release)
2991+
value = ngx.HTTP_CLOSE (444) (first added in the v0.9.20 release)
2992+
value = ngx.HTTP_ILLEGAL (451) (first added in the v0.9.20 release)
29792993
value = ngx.HTTP_INTERNAL_SERVER_ERROR (500)
29802994
value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501)
2995+
value = ngx.HTTP_BAD_GATEWAY (502) (first added in the v0.9.20 release)
29812996
value = ngx.HTTP_SERVICE_UNAVAILABLE (503)
29822997
value = ngx.HTTP_GATEWAY_TIMEOUT (504) (first added in the v0.3.1rc38 release)
2998+
value = ngx.HTTP_VERSION_NOT_SUPPORTED (505) (first added in the v0.9.20 release)
2999+
value = ngx.HTTP_INSUFFICIENT_STORAGE (507) (first added in the v0.9.20 release)
29833000
```
29843001

29853002
[Back to TOC](#nginx-api-for-lua)

doc/HttpLuaModule.wiki

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,23 +2371,40 @@ These constants are usually used in [[#ngx.location.capture|ngx.location.capture
23712371
'''context:''' ''init_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua, log_by_lua*, ngx.timer.*''
23722372
23732373
<geshi lang="nginx">
2374+
value = ngx.HTTP_CONTINUE (100) (first added in the v0.9.20 release)
2375+
value = ngx.HTTP_SWITCHING_PROTOCOLS (101) (first added in the v0.9.20 release)
23742376
value = ngx.HTTP_OK (200)
23752377
value = ngx.HTTP_CREATED (201)
2378+
value = ngx.HTTP_ACCEPTED (202) (first added in the v0.9.20 release)
2379+
value = ngx.HTTP_NO_CONTENT (204) (first added in the v0.9.20 release)
2380+
value = ngx.HTTP_PARTIAL_CONTENT (206) (first added in the v0.9.20 release)
23762381
value = ngx.HTTP_SPECIAL_RESPONSE (300)
23772382
value = ngx.HTTP_MOVED_PERMANENTLY (301)
23782383
value = ngx.HTTP_MOVED_TEMPORARILY (302)
23792384
value = ngx.HTTP_SEE_OTHER (303)
23802385
value = ngx.HTTP_NOT_MODIFIED (304)
2386+
value = ngx.HTTP_TEMPORARY_REDIRECT (307) (first added in the v0.9.20 release)
23812387
value = ngx.HTTP_BAD_REQUEST (400)
23822388
value = ngx.HTTP_UNAUTHORIZED (401)
2389+
value = ngx.HTTP_PAYMENT_REQUIRED (402) (first added in the v0.9.20 release)
23832390
value = ngx.HTTP_FORBIDDEN (403)
23842391
value = ngx.HTTP_NOT_FOUND (404)
23852392
value = ngx.HTTP_NOT_ALLOWED (405)
2393+
value = ngx.HTTP_NOT_ACCEPTABLE (406) (first added in the v0.9.20 release)
2394+
value = ngx.HTTP_REQUEST_TIMEOUT (408) (first added in the v0.9.20 release)
2395+
value = ngx.HTTP_CONFLICT (409) (first added in the v0.9.20 release)
23862396
value = ngx.HTTP_GONE (410)
2397+
value = ngx.HTTP_UPGRADE_REQUIRED (426) (first added in the v0.9.20 release)
2398+
value = ngx.HTTP_TOO_MANY_REQUESTS (429) (first added in the v0.9.20 release)
2399+
value = ngx.HTTP_CLOSE (444) (first added in the v0.9.20 release)
2400+
value = ngx.HTTP_ILLEGAL (451) (first added in the v0.9.20 release)
23872401
value = ngx.HTTP_INTERNAL_SERVER_ERROR (500)
23882402
value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501)
2403+
value = ngx.HTTP_BAD_GATEWAY (502) (first added in the v0.9.20 release)
23892404
value = ngx.HTTP_SERVICE_UNAVAILABLE (503)
23902405
value = ngx.HTTP_GATEWAY_TIMEOUT (504) (first added in the v0.3.1rc38 release)
2406+
value = ngx.HTTP_VERSION_NOT_SUPPORTED (505) (first added in the v0.9.20 release)
2407+
value = ngx.HTTP_INSUFFICIENT_STORAGE (507) (first added in the v0.9.20 release)
23912408
</geshi>
23922409
23932410
== Nginx log level constants ==

src/ngx_http_lua_consts.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,27 @@ ngx_http_lua_inject_http_consts(lua_State *L)
8989
lua_setfield(L, -2, "HTTP_TRACE");
9090
/* }}} */
9191

92+
lua_pushinteger(L, NGX_HTTP_CONTINUE);
93+
lua_setfield(L, -2, "HTTP_CONTINUE");
94+
95+
lua_pushinteger(L, NGX_HTTP_SWITCHING_PROTOCOLS);
96+
lua_setfield(L, -2, "HTTP_SWITCHING_PROTOCOLS");
97+
9298
lua_pushinteger(L, NGX_HTTP_OK);
9399
lua_setfield(L, -2, "HTTP_OK");
94100

95101
lua_pushinteger(L, NGX_HTTP_CREATED);
96102
lua_setfield(L, -2, "HTTP_CREATED");
97103

104+
lua_pushinteger(L, NGX_HTTP_ACCEPTED);
105+
lua_setfield(L, -2, "HTTP_ACCEPTED");
106+
107+
lua_pushinteger(L, NGX_HTTP_NO_CONTENT);
108+
lua_setfield(L, -2, "HTTP_NO_CONTENT");
109+
110+
lua_pushinteger(L, NGX_HTTP_PARTIAL_CONTENT);
111+
lua_setfield(L, -2, "HTTP_PARTIAL_CONTENT");
112+
98113
lua_pushinteger(L, NGX_HTTP_SPECIAL_RESPONSE);
99114
lua_setfield(L, -2, "HTTP_SPECIAL_RESPONSE");
100115

@@ -121,6 +136,8 @@ ngx_http_lua_inject_http_consts(lua_State *L)
121136
lua_pushinteger(L, NGX_HTTP_UNAUTHORIZED);
122137
lua_setfield(L, -2, "HTTP_UNAUTHORIZED");
123138

139+
lua_pushinteger(L, 402);
140+
lua_setfield(L, -2, "HTTP_PAYMENT_REQUIRED");
124141

125142
lua_pushinteger(L, NGX_HTTP_FORBIDDEN);
126143
lua_setfield(L, -2, "HTTP_FORBIDDEN");
@@ -131,20 +148,51 @@ ngx_http_lua_inject_http_consts(lua_State *L)
131148
lua_pushinteger(L, NGX_HTTP_NOT_ALLOWED);
132149
lua_setfield(L, -2, "HTTP_NOT_ALLOWED");
133150

151+
lua_pushinteger(L, 406);
152+
lua_setfield(L, -2, "HTTP_NOT_ACCEPTABLE");
153+
154+
lua_pushinteger(L, NGX_HTTP_REQUEST_TIME_OUT);
155+
lua_setfield(L, -2, "HTTP_REQUEST_TIMEOUT");
156+
157+
lua_pushinteger(L, NGX_HTTP_CONFLICT);
158+
lua_setfield(L, -2, "HTTP_CONFLICT");
159+
134160
lua_pushinteger(L, 410);
135161
lua_setfield(L, -2, "HTTP_GONE");
136162

163+
lua_pushinteger(L, 426);
164+
lua_setfield(L, -2, "HTTP_UPGRADE_REQUIRED");
165+
166+
lua_pushinteger(L, 429);
167+
lua_setfield(L, -2, "HTTP_TOO_MANY_REQUESTS");
168+
169+
lua_pushinteger(L, 451);
170+
lua_setfield(L, -2, "HTTP_ILLEGAL");
171+
172+
lua_pushinteger(L, NGX_HTTP_CLOSE);
173+
lua_setfield(L, -2, "HTTP_CLOSE");
174+
137175
lua_pushinteger(L, NGX_HTTP_INTERNAL_SERVER_ERROR);
138176
lua_setfield(L, -2, "HTTP_INTERNAL_SERVER_ERROR");
139177

140178
lua_pushinteger(L, NGX_HTTP_NOT_IMPLEMENTED);
141179
lua_setfield(L, -2, "HTTP_METHOD_NOT_IMPLEMENTED");
142180

181+
lua_pushinteger(L, NGX_HTTP_BAD_GATEWAY);
182+
lua_setfield(L, -2, "HTTP_BAD_GATEWAY");
183+
143184
lua_pushinteger(L, NGX_HTTP_SERVICE_UNAVAILABLE);
144185
lua_setfield(L, -2, "HTTP_SERVICE_UNAVAILABLE");
145186

146187
lua_pushinteger(L, NGX_HTTP_GATEWAY_TIME_OUT);
147188
lua_setfield(L, -2, "HTTP_GATEWAY_TIMEOUT");
189+
190+
lua_pushinteger(L, 505);
191+
lua_setfield(L, -2, "HTTP_VERSION_NOT_SUPPORTED");
192+
193+
lua_pushinteger(L, NGX_HTTP_INSUFFICIENT_STORAGE);
194+
lua_setfield(L, -2, "HTTP_INSUFFICIENT_STORAGE");
195+
148196
/* }}} */
149197
}
150198

0 commit comments

Comments
 (0)