comparison src/http/modules/perl/nginx.xs @ 601:77f77f53214a release-0.3.22

nginx-0.3.22-RELEASE import *) Feature: the ngx_http_perl_module supports the $r->args and $r->unescape methods. *) Feature: the method $r->query_string of ngx_http_perl_module was canceled. *) Bugfix: segmentation fault was occurred if the "none" or "blocked" values was specified in the "valid_referers" directive; the bug had appeared in 0.3.18.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 17 Jan 2006 20:04:32 +0000
parents 869b6444d234
children 858700ae46b4
comparison
equal deleted inserted replaced
600:2d3a5a03e738 601:77f77f53214a
154 OUTPUT: 154 OUTPUT:
155 RETVAL 155 RETVAL
156 156
157 157
158 char * 158 char *
159 query_string(r, ...) 159 args(r, ...)
160 nginx r 160 nginx r
161 161
162 CODE: 162 CODE:
163 163
164 if (items != 1) { 164 if (items != 1) {
165 croak("$r->query_string(text) is not implemented"); 165 croak("$r->args(text) is not implemented");
166 } 166 }
167 167
168 RETVAL = ngx_palloc(r->pool, r->args.len + 1); 168 RETVAL = ngx_palloc(r->pool, r->args.len + 1);
169 if (RETVAL == NULL) { 169 if (RETVAL == NULL) {
170 XSRETURN_UNDEF; 170 XSRETURN_UNDEF;
358 b->pos = p; 358 b->pos = p;
359 b->last = p + len; 359 b->last = p + len;
360 b->start = p; 360 b->start = p;
361 b->end = b->last; 361 b->end = b->last;
362 362
363 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
364 "$r->print: read-only SV: %z", len);
365
363 goto out; 366 goto out;
364 } 367 }
365 } 368 }
366 369
367 size = 0; 370 size = 0;
372 375
373 if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PV) { 376 if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PV) {
374 sv = SvRV(sv); 377 sv = SvRV(sv);
375 } 378 }
376 379
377 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
378 "SV: %p %d %Xd",
379 sv, SvREFCNT(sv), SvREADONLY(sv));
380
381 (void) SvPV(sv, len); 380 (void) SvPV(sv, len);
381
382 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
383 "$r->print: copy SV: %z", len);
382 384
383 size += len; 385 size += len;
384 } 386 }
385 387
386 if (size == 0) { 388 if (size == 0) {
511 goto done; 513 goto done;
512 } 514 }
513 515
514 b->flush = 1; 516 b->flush = 1;
515 517
518 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "$r->rflush");
519
516 RETVAL = ngx_http_perl_output(r, b); 520 RETVAL = ngx_http_perl_output(r, b);
517 521
518 done: 522 done:
519 523
520 OUTPUT: 524 OUTPUT:
547 ctx->redirect_uri.len = i; 551 ctx->redirect_uri.len = i;
548 552
549 XSRETURN_EMPTY; 553 XSRETURN_EMPTY;
550 } 554 }
551 } 555 }
556
557
558 char *
559 unescape(r, text, type = 0)
560 nginx r
561 SV *text
562 int type
563
564 PREINIT:
565
566 u_char *p, *dst, *src;
567 STRLEN n;
568
569 CODE:
570
571 src = (u_char *) SvPV(text, n);
572
573 p = ngx_palloc(r->pool, n + 1);
574 if (p == NULL) {
575 XSRETURN_UNDEF;
576 }
577
578 dst = p;
579
580 ngx_unescape_uri(&dst, &src, n, (ngx_uint_t) type);
581 *dst = '\0';
582
583 RETVAL = (char *) p;
584
585 OUTPUT:
586 RETVAL