request body problem

dr-dr xp drdr.xp at gmail.com
Wed Apr 22 07:29:47 MSD 2009


I do not know if it is a bug or design intention: if request body client
sent is larger than the amount Content-Length specified . The addition data
is also received and dealt in an incorrect way.

If content-length is smaller :
1) sending a PUT request to webdav module, addition data is written also in
to file.

2) proxy module behave wrongly, it closes client connection.

To avoid such problems:

@@ -1,4 +1,3 @@
-
 /*
  * Copyright (C) Igor Sysoev
  */
@@ -133,9 +132,12 @@ ngx_http_read_client_request_body(ngx_ht
         rb->buf = b;

         if ((off_t) preread >= r->headers_in.content_length_n) {
-
             /* the whole request body was pre-read */

+            b->last = b->pos + r->headers_in.content_length_n;
+            preread = r->headers_in.content_length_n;
+
+
             r->header_in->pos += (size_t) r->headers_in.content_length_n;
             r->request_length += r->headers_in.content_length_n;

@@ -267,8 +269,17 @@ ngx_http_do_read_client_request_body(ngx
     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
                    "http read client request body");

+
     for ( ;; ) {
-        for ( ;; ) {
+      if (rb->rest == 0) {
+        /* dicard */
+        char buf[1024];
+        n = 1;
+        while (n > 0)
+          n = c->recv(c, buf, 1024);
+        return NGX_OK;
+      }
+        for ( ;rb->rest != 0; ) {
             if (rb->buf->last == rb->buf->end) {

                 if (ngx_http_write_request_body(r, rb->to_write) != NGX_OK)
{




-- 
要了几天饱饭就不记得西北风啥味了
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090422/e3a7aaea/attachment.html>


More information about the nginx mailing list