Welcome! Log In Create A New Profile

Advanced

[nginx] svn commit: r5182 - trunk/src/http/modules/perl

Anonymous User
April 23, 2013 06:06AM
Author: mdounin
Date: 2013-04-23 10:04:12 +0000 (Tue, 23 Apr 2013)
New Revision: 5182
URL: http://trac.nginx.org/nginx/changeset/5182/nginx

Log:
Perl: request body handling fixed.

As of 1.3.9, chunked request body may be available with
r->headers_in.content_length_n <= 0. Additionally, request body
may be in multiple buffers even if r->request_body_in_single_buf
was requested.


Modified:
trunk/src/http/modules/perl/nginx.xs

Modified: trunk/src/http/modules/perl/nginx.xs
===================================================================
--- trunk/src/http/modules/perl/nginx.xs 2013-04-19 12:19:57 UTC (rev 5181)
+++ trunk/src/http/modules/perl/nginx.xs 2013-04-23 10:04:12 UTC (rev 5182)
@@ -357,7 +357,7 @@

ngx_http_perl_set_request(r);

- if (r->headers_in.content_length_n <= 0) {
+ if (r->headers_in.content_length_n <= 0 && !r->headers_in.chunked) {
XSRETURN_UNDEF;
}

@@ -386,7 +386,10 @@

dXSTARG;
ngx_http_request_t *r;
+ u_char *p, *data;
size_t len;
+ ngx_buf_t *buf;
+ ngx_chain_t *cl;

ngx_http_perl_set_request(r);

@@ -397,13 +400,43 @@
XSRETURN_UNDEF;
}

- len = r->request_body->bufs->buf->last - r->request_body->bufs->buf->pos;
+ cl = r->request_body->bufs;
+ buf = cl->buf;

+ if (cl->next == NULL) {
+ len = buf->last - buf->pos;
+ data = buf->pos;
+ goto done;
+ }
+
+ len = buf->last - buf->pos;
+ cl = cl->next;
+
+ for ( /* void */ ; cl; cl = cl->next) {
+ buf = cl->buf;
+ len += buf->last - buf->pos;
+ }
+
+ p = ngx_pnalloc(r->pool, len);
+ if (p == NULL) {
+ return XSRETURN_UNDEF;
+ }
+
+ data = p;
+ cl = r->request_body->bufs;
+
+ for ( /* void */ ; cl; cl = cl->next) {
+ buf = cl->buf;
+ p = ngx_cpymem(p, buf->pos, buf->last - buf->pos);
+ }
+
+ done:
+
if (len == 0) {
XSRETURN_UNDEF;
}

- ngx_http_perl_set_targ(r->request_body->bufs->buf->pos, len);
+ ngx_http_perl_set_targ(data, len);

ST(0) = TARG;


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] svn commit: r5182 - trunk/src/http/modules/perl

Anonymous User 826 April 23, 2013 06:06AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 171
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready