comparison src/http/modules/perl/ngx_http_perl_module.c @ 178:87699398f955 NGINX_0_3_36

nginx 0.3.36 *) Feature: the ngx_http_addition_filter_module. *) Feature: the "proxy_pass" and "fastcgi_pass" directives may be used inside the "if" block. *) Feature: the "proxy_ignore_client_abort" and "fastcgi_ignore_client_abort" directives. *) Feature: the "$request_completion" variable. *) Feature: the ngx_http_perl_module supports the $r->request_method and $r->remote_addr. *) Feature: the ngx_http_ssi_module supports the "elif" command. *) Bugfix: the "\/" string in the expression of the "if" command of the ngx_http_ssi_module was treated incorrectly. *) Bugfix: in the regular expressions in the "if" command of the ngx_http_ssi_module. *) Bugfix: if the relative path was specified in the "client_body_temp_path", "proxy_temp_path", "fastcgi_temp_path", and "perl_modules" directives, then the directory was used relatively to a current path but not to a server prefix.
author Igor Sysoev <http://sysoev.ru>
date Wed, 05 Apr 2006 00:00:00 +0400
parents 1b490fc19afa
children 13710a1813ad
comparison
equal deleted inserted replaced
177:4a3ddd758222 178:87699398f955
37 #if (NGX_HTTP_SSI) 37 #if (NGX_HTTP_SSI)
38 static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r, 38 static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r,
39 ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params); 39 ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params);
40 #endif 40 #endif
41 41
42 static void ngx_http_perl_handle_request(ngx_http_request_t *r);
42 static ngx_int_t 43 static ngx_int_t
43 ngx_http_perl_get_interpreter(ngx_http_perl_main_conf_t *pmcf, 44 ngx_http_perl_get_interpreter(ngx_http_perl_main_conf_t *pmcf,
44 PerlInterpreter **perl, ngx_log_t *log); 45 PerlInterpreter **perl, ngx_log_t *log);
45 static ngx_inline void 46 static ngx_inline void
46 ngx_http_perl_free_interpreter(ngx_http_perl_main_conf_t *pmcf, 47 ngx_http_perl_free_interpreter(ngx_http_perl_main_conf_t *pmcf,
172 173
173 174
174 static ngx_int_t 175 static ngx_int_t
175 ngx_http_perl_handler(ngx_http_request_t *r) 176 ngx_http_perl_handler(ngx_http_request_t *r)
176 { 177 {
178 ngx_int_t rc;
179
180 /* TODO: Win32 */
181 if (r->zero_in_uri) {
182 return NGX_HTTP_NOT_FOUND;
183 }
184
185 rc = ngx_http_read_client_request_body(r, ngx_http_perl_handle_request);
186
187 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
188 return rc;
189 }
190
191 return NGX_DONE;
192 }
193
194
195 static void
196 ngx_http_perl_handle_request(ngx_http_request_t *r)
197 {
177 ngx_int_t rc; 198 ngx_int_t rc;
178 ngx_str_t uri, args; 199 ngx_str_t uri, args;
179 ngx_http_perl_ctx_t *ctx; 200 ngx_http_perl_ctx_t *ctx;
180 ngx_http_perl_loc_conf_t *plcf; 201 ngx_http_perl_loc_conf_t *plcf;
181 ngx_http_perl_main_conf_t *pmcf; 202 ngx_http_perl_main_conf_t *pmcf;
182 203
183 /* TODO: Win32 */
184 if (r->zero_in_uri) {
185 return NGX_HTTP_NOT_FOUND;
186 }
187
188 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "perl handler"); 204 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "perl handler");
189 205
190 /* mod_perl's content handler assumes that content type was already set */ 206 /* mod_perl's content handler assumes that content type was already set */
191 207
192 if (ngx_http_set_content_type(r) != NGX_OK) { 208 if (ngx_http_set_content_type(r) != NGX_OK) {
193 return NGX_HTTP_INTERNAL_SERVER_ERROR; 209 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
210 return;
194 } 211 }
195 212
196 ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module); 213 ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module);
197 214
198 if (ctx == NULL) { 215 if (ctx == NULL) {
199 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_perl_ctx_t)); 216 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_perl_ctx_t));
200 if (ctx == NULL) { 217 if (ctx == NULL) {
201 return NGX_ERROR; 218 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
219 return;
202 } 220 }
203 221
204 ngx_http_set_ctx(r, ctx, ngx_http_perl_module); 222 ngx_http_set_ctx(r, ctx, ngx_http_perl_module);
205 } 223 }
206 224
207 pmcf = ngx_http_get_module_main_conf(r, ngx_http_perl_module); 225 pmcf = ngx_http_get_module_main_conf(r, ngx_http_perl_module);
208 226
209 rc = ngx_http_perl_get_interpreter(pmcf, &ctx->perl, r->connection->log); 227 rc = ngx_http_perl_get_interpreter(pmcf, &ctx->perl, r->connection->log);
210 228
211 if (rc != NGX_OK) { 229 if (rc != NGX_OK) {
212 return rc; 230 ngx_http_finalize_request(r, rc);
231 return;
213 } 232 }
214 233
215 { 234 {
216 235
217 dTHXa(ctx->perl); 236 dTHXa(ctx->perl);
233 "perl handler done: %i", rc); 252 "perl handler done: %i", rc);
234 253
235 if (ctx->redirect_uri.len) { 254 if (ctx->redirect_uri.len) {
236 uri = ctx->redirect_uri; 255 uri = ctx->redirect_uri;
237 args = ctx->redirect_args; 256 args = ctx->redirect_args;
257
258 } else {
259 uri.len = 0;
238 } 260 }
239 261
240 ctx->filename = NULL; 262 ctx->filename = NULL;
241 ctx->redirect_uri.len = 0; 263 ctx->redirect_uri.len = 0;
242 264
243 if (uri.len) { 265 if (uri.len) {
244 return ngx_http_internal_redirect(r, &uri, &args); 266 ngx_http_internal_redirect(r, &uri, &args);
267 return;
245 } 268 }
246 269
247 if (rc == NGX_OK || rc == NGX_HTTP_OK) { 270 if (rc == NGX_OK || rc == NGX_HTTP_OK) {
248 return ngx_http_send_special(r, NGX_HTTP_LAST); 271 ngx_http_send_special(r, NGX_HTTP_LAST);
249 } 272 }
250 273
251 return rc; 274 ngx_http_finalize_request(r, rc);
252 } 275 }
253 276
254 277
255 static ngx_int_t 278 static ngx_int_t
256 ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, 279 ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
445 #ifdef NGX_PERL_MODULES 468 #ifdef NGX_PERL_MODULES
446 if (pmcf->modules.data == NULL) { 469 if (pmcf->modules.data == NULL) {
447 pmcf->modules.data = NGX_PERL_MODULES; 470 pmcf->modules.data = NGX_PERL_MODULES;
448 } 471 }
449 #endif 472 #endif
473
474 if (ngx_conf_full_name(cf->cycle, &pmcf->modules) != NGX_OK) {
475 return NGX_CONF_ERROR;
476 }
450 477
451 PERL_SYS_INIT(&ngx_argc, &ngx_argv); 478 PERL_SYS_INIT(&ngx_argc, &ngx_argv);
452 479
453 pmcf->perl = ngx_http_perl_create_interpreter(pmcf, cf->log); 480 pmcf->perl = ngx_http_perl_create_interpreter(pmcf, cf->log);
454 481