diff options
author | Igor Sysoev <igor@sysoev.ru> | 2006-08-30 10:39:17 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2006-08-30 10:39:17 +0000 |
commit | da173abde0afa26b02c778d6475462ed487594c5 (patch) | |
tree | 25362ec56c889a2284e6feb341d5b87f13b5beab /src/http/modules/perl | |
parent | 9cdd8a1cbcf70527db51eeab707a5bc05babdcf3 (diff) | |
download | nginx-release-0.4.0.tar.gz nginx-release-0.4.0.zip |
nginx-0.4.0-RELEASE importrelease-0.4.0
*) Change in internal API: the HTTP modules initialization was moved
from the init module phase to the HTTP postconfiguration phase.
*) Change: now the request body is not read beforehand for the
ngx_http_perl_module: it's required to start the reading using the
$r->has_request_body method.
*) Feature: the ngx_http_perl_module supports the DECLINED return code.
*) Feature: the ngx_http_dav_module supports the incoming "Date" header
line for the PUT method.
*) Feature: the "ssi" directive is available inside the "if" block.
*) Bugfix: a segmentation fault occurred if there was an "index"
directive with variables and the first index name was without
variables; the bug had appeared in 0.1.29.
Diffstat (limited to 'src/http/modules/perl')
-rw-r--r-- | src/http/modules/perl/Makefile.PL | 7 | ||||
-rw-r--r-- | src/http/modules/perl/nginx.pm | 2 | ||||
-rw-r--r-- | src/http/modules/perl/nginx.xs | 36 | ||||
-rw-r--r-- | src/http/modules/perl/ngx_http_perl_module.c | 51 | ||||
-rw-r--r-- | src/http/modules/perl/ngx_http_perl_module.h | 6 |
5 files changed, 76 insertions, 26 deletions
diff --git a/src/http/modules/perl/Makefile.PL b/src/http/modules/perl/Makefile.PL index 48f1ebcd2..c33b1fc72 100644 --- a/src/http/modules/perl/Makefile.PL +++ b/src/http/modules/perl/Makefile.PL @@ -12,7 +12,7 @@ WriteMakefile( ABSTRACT_FROM => 'nginx.pm', # retrieve abstract from module AUTHOR => 'Igor Sysoev', - CCFLAGS => "$ENV{NGX_PERL_CFLAGS}", + CCFLAGS => "$ENV{NGX_PM_CFLAGS}", OPTIMIZE => '-O', INC => "-I ../../../../../src/core " . @@ -22,8 +22,9 @@ WriteMakefile( "-I ../../../../../src/http/modules " . "-I ../../../../../src/http/modules/perl " . "-I ../../../../../$ENV{NGX_OBJS} " . - "-I ../../../../../$ENV{NGX_PCRE} " . - "-I ../../../../../$ENV{NGX_ZLIB} ", + ($ENV{NGX_PCRE} =~ /^(YES|NO)/ ? "" : + ($ENV{NGX_PCRE} =~ m#^/# ? "-I $ENV{NGX_PCRE} " : + "-I ../../../../../$ENV{NGX_PCRE} ")), depend => { 'nginx.c' => diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm index badd494b4..309eaa545 100644 --- a/src/http/modules/perl/nginx.pm +++ b/src/http/modules/perl/nginx.pm @@ -17,7 +17,7 @@ our @EXPORT = qw( HTTP_SERVER_ERROR ); -our $VERSION = '0.3.43'; +our $VERSION = '0.4.0'; require XSLoader; XSLoader::load('nginx', $VERSION); diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs index 53b6a9230..6e6afed15 100644 --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -329,6 +329,42 @@ header_in(r, key) void +has_request_body(r, next) + CODE: + + dXSTARG; + ngx_http_request_t *r; + SV *next; + ngx_http_perl_ctx_t *ctx; + + ngx_http_perl_set_request(r); + + if (r->headers_in.content_length_n <= 0) { + XSRETURN_UNDEF; + } + + next = ST(1); + + ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module); + ctx->next = next; + + r->request_body_in_single_buf = 1; + r->request_body_in_persistent_file = 1; + r->request_body_delete_incomplete_file = 1; + + if (r->request_body_in_file_only) { + r->request_body_file_log_level = 0; + } + + ngx_http_read_client_request_body(r, ngx_http_perl_handle_request); + + sv_upgrade(TARG, SVt_IV); + sv_setiv(TARG, 1); + + ST(0) = TARG; + + +void request_body(r) CODE: diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c index 6f979c661..e59ece4bb 100644 --- a/src/http/modules/perl/ngx_http_perl_module.c +++ b/src/http/modules/perl/ngx_http_perl_module.c @@ -45,7 +45,6 @@ static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params); #endif -static void ngx_http_perl_handle_request(ngx_http_request_t *r); static ngx_int_t ngx_http_perl_get_interpreter(ngx_http_perl_main_conf_t *pmcf, PerlInterpreter **perl, ngx_log_t *log); @@ -176,6 +175,9 @@ static ngx_http_ssi_command_t ngx_http_perl_ssi_command = { #endif +static ngx_str_t ngx_null_name = ngx_null_string; + + static HV *nginx_stash; static void @@ -190,13 +192,16 @@ ngx_http_perl_xs_init(pTHX) static ngx_int_t ngx_http_perl_handler(ngx_http_request_t *r) { - ngx_int_t rc; - /* TODO: Win32 */ if (r->zero_in_uri) { return NGX_HTTP_NOT_FOUND; } + ngx_http_perl_handle_request(r); + + return NGX_DONE; + +#if 0 r->request_body_in_single_buf = 1; r->request_body_in_persistent_file = 1; r->request_body_delete_incomplete_file = 1; @@ -212,14 +217,16 @@ ngx_http_perl_handler(ngx_http_request_t *r) } return NGX_DONE; +#endif } -static void +void ngx_http_perl_handle_request(ngx_http_request_t *r) { + SV *sub; ngx_int_t rc; - ngx_str_t uri, args; + ngx_str_t uri, args, *handler; ngx_http_perl_ctx_t *ctx; ngx_http_perl_loc_conf_t *plcf; ngx_http_perl_main_conf_t *pmcf; @@ -231,7 +238,7 @@ ngx_http_perl_handle_request(ngx_http_request_t *r) if (ctx == NULL) { ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_perl_ctx_t)); if (ctx == NULL) { - ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); + ngx_http_finalize_request(r, NGX_ERROR); return; } @@ -251,10 +258,18 @@ ngx_http_perl_handle_request(ngx_http_request_t *r) dTHXa(ctx->perl); - plcf = ngx_http_get_module_loc_conf(r, ngx_http_perl_module); + if (ctx->next == NULL) { + plcf = ngx_http_get_module_loc_conf(r, ngx_http_perl_module); + sub = plcf->sub; + handler = &plcf->handler; + + } else { + sub = ctx->next; + handler = &ngx_null_name; + ctx->next = NULL; + } - rc = ngx_http_perl_call_handler(aTHX_ r, plcf->sub, NULL, - &plcf->handler, NULL); + rc = ngx_http_perl_call_handler(aTHX_ r, sub, NULL, handler, NULL); } @@ -278,6 +293,10 @@ ngx_http_perl_handle_request(ngx_http_request_t *r) ctx->filename.data = NULL; ctx->redirect_uri.len = 0; + if (ctx->done || ctx->next) { + return; + } + if (uri.len) { ngx_http_internal_redirect(r, &uri, &args); return; @@ -285,6 +304,7 @@ ngx_http_perl_handle_request(ngx_http_request_t *r) if (rc == NGX_OK || rc == NGX_HTTP_OK) { ngx_http_send_special(r, NGX_HTTP_LAST); + ctx->done = 1; } ngx_http_finalize_request(r, rc); @@ -666,14 +686,6 @@ ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log) } -#if (__INTEL_COMPILER) -/* - * disable 'declaration hides parameter "my_perl"' warning for ENTER and LEAVE - */ -#pragma warning(disable:1599) -#endif - - static ngx_int_t ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, SV *sub, ngx_str_t **args, ngx_str_t *handler, ngx_str_t *rv) @@ -773,11 +785,6 @@ ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, SV *sub, } -#if (__INTEL_COMPILER) -#pragma warning(default:1599) -#endif - - static void ngx_http_perl_eval_anon_sub(pTHX_ ngx_str_t *handler, SV **sv) { diff --git a/src/http/modules/perl/ngx_http_perl_module.h b/src/http/modules/perl/ngx_http_perl_module.h index 1609c478b..66d15da1c 100644 --- a/src/http/modules/perl/ngx_http_perl_module.h +++ b/src/http/modules/perl/ngx_http_perl_module.h @@ -24,6 +24,9 @@ typedef struct { ngx_str_t filename; ngx_str_t redirect_uri; ngx_str_t redirect_args; + SV *next; + + ngx_uint_t done; /* unsigned done:1; */ #if (NGX_HTTP_SSI) ngx_http_ssi_ctx_t *ssi; @@ -47,4 +50,7 @@ extern ngx_module_t ngx_http_perl_module; extern void boot_DynaLoader(pTHX_ CV* cv); +void ngx_http_perl_handle_request(ngx_http_request_t *r); + + #endif /* _NGX_HTTP_PERL_MODULE_H_INCLUDED_ */ |