Skip to content

Commit 5483b91

Browse files
karai17zhuizhuhaomeng
authored andcommitted
feature: added http const HTTP_NOT_IMPLEMENTED, fixes #1466.
Co-authored-by: lijunlong <lijunllong@openrestycom>
1 parent 37ec9f7 commit 5483b91

File tree

6 files changed

+29
-7
lines changed

6 files changed

+29
-7
lines changed

README.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3875,7 +3875,8 @@ HTTP status constants
38753875
value = ngx.HTTP_CLOSE (444) (first added in the v0.9.20 release)
38763876
value = ngx.HTTP_ILLEGAL (451) (first added in the v0.9.20 release)
38773877
value = ngx.HTTP_INTERNAL_SERVER_ERROR (500)
3878-
value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501)
3878+
value = ngx.HTTP_NOT_IMPLEMENTED (501)
3879+
value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501) (kept for compatibility)
38793880
value = ngx.HTTP_BAD_GATEWAY (502) (first added in the v0.9.20 release)
38803881
value = ngx.HTTP_SERVICE_UNAVAILABLE (503)
38813882
value = ngx.HTTP_GATEWAY_TIMEOUT (504) (first added in the v0.3.1rc38 release)

doc/HttpLuaModule.wiki

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3178,7 +3178,8 @@ These constants are usually used in [[#ngx.location.capture|ngx.location.capture
31783178
value = ngx.HTTP_CLOSE (444) (first added in the v0.9.20 release)
31793179
value = ngx.HTTP_ILLEGAL (451) (first added in the v0.9.20 release)
31803180
value = ngx.HTTP_INTERNAL_SERVER_ERROR (500)
3181-
value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501)
3181+
value = ngx.HTTP_NOT_IMPLEMENTED (501)
3182+
value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501) (kept for compatibility)
31823183
value = ngx.HTTP_BAD_GATEWAY (502) (first added in the v0.9.20 release)
31833184
value = ngx.HTTP_SERVICE_UNAVAILABLE (503)
31843185
value = ngx.HTTP_GATEWAY_TIMEOUT (504) (first added in the v0.3.1rc38 release)

src/ngx_http_lua_consts.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ ngx_http_lua_inject_http_consts(lua_State *L)
176176
lua_pushinteger(L, NGX_HTTP_INTERNAL_SERVER_ERROR);
177177
lua_setfield(L, -2, "HTTP_INTERNAL_SERVER_ERROR");
178178

179+
lua_pushinteger(L, NGX_HTTP_NOT_IMPLEMENTED);
180+
lua_setfield(L, -2, "HTTP_NOT_IMPLEMENTED");
181+
182+
/* keep for backward compatibility */
179183
lua_pushinteger(L, NGX_HTTP_NOT_IMPLEMENTED);
180184
lua_setfield(L, -2, "HTTP_METHOD_NOT_IMPLEMENTED");
181185

src/ngx_http_lua_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ static void
827827
ngx_http_lua_inject_ngx_api(lua_State *L, ngx_http_lua_main_conf_t *lmcf,
828828
ngx_log_t *log)
829829
{
830-
lua_createtable(L, 0 /* narr */, 113 /* nrec */); /* ngx.* */
830+
lua_createtable(L, 0 /* narr */, 115 /* nrec */); /* ngx.* */
831831

832832
lua_pushcfunction(L, ngx_http_lua_get_raw_phase_context);
833833
lua_setfield(L, -2, "_phase_ctx");

t/005-exit.t

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,3 +724,19 @@ GET /t
724724
--- response_body
725725
--- no_error_log
726726
[error]
727+
728+
729+
730+
=== TEST 25: 501 Method Not Implemented
731+
--- config
732+
location /lua {
733+
content_by_lua '
734+
ngx.exit(ngx.HTTP_NOT_IMPLEMENTED)
735+
';
736+
}
737+
--- request
738+
GET /lua
739+
--- error_code: 501
740+
--- response_body_like: 501 (?:Method )?Not Implemented
741+
--- no_error_log
742+
[error]

t/062-count.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ __DATA__
3434
--- request
3535
GET /test
3636
--- response_body
37-
ngx: 114
37+
ngx: 115
3838
--- no_error_log
3939
[error]
4040

@@ -55,7 +55,7 @@ ngx: 114
5555
--- request
5656
GET /test
5757
--- response_body
58-
114
58+
115
5959
--- no_error_log
6060
[error]
6161

@@ -83,7 +83,7 @@ GET /test
8383
--- request
8484
GET /test
8585
--- response_body
86-
n = 114
86+
n = 115
8787
--- no_error_log
8888
[error]
8989

@@ -305,7 +305,7 @@ GET /t
305305
--- response_body_like: 404 Not Found
306306
--- error_code: 404
307307
--- error_log
308-
ngx. entry count: 114
308+
ngx. entry count: 115
309309

310310

311311

0 commit comments

Comments
 (0)