diff src/http/modules/ngx_http_range_filter_module.c @ 501:d4ea69372b94 release-0.1.25

nginx-0.1.25-RELEASE import *) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author Igor Sysoev <igor@sysoev.ru>
date Sat, 19 Mar 2005 12:38:37 +0000
parents src/http/modules/ngx_http_range_filter.c@64d9afb209da
children 9b8c906f6e63
line wrap: on
line diff
copy from src/http/modules/ngx_http_range_filter.c
copy to src/http/modules/ngx_http_range_filter_module.c
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -186,7 +186,8 @@ ngx_http_range_header_filter(ngx_http_re
             while (*p == ' ') { p++; }
 
             if (*p == ',' || *p == '\0') {
-                if (!(range = ngx_array_push(&r->headers_out.ranges))) {
+                range = ngx_array_push(&r->headers_out.ranges);
+                if (range == NULL) {
                     return NGX_ERROR;
                 }
 
@@ -231,7 +232,8 @@ ngx_http_range_header_filter(ngx_http_re
             break;
         }
 
-        if (!(range = ngx_array_push(&r->headers_out.ranges))) {
+        range = ngx_array_push(&r->headers_out.ranges);
+        if (range == NULL) {
             return NGX_ERROR;
         }
 
@@ -260,7 +262,8 @@ ngx_http_range_header_filter(ngx_http_re
         r->headers_out.status = rc;
         r->headers_out.ranges.nelts = 0;
 
-        if (!(content_range = ngx_list_push(&r->headers_out.headers))) {
+        content_range = ngx_list_push(&r->headers_out.headers);
+        if (content_range == NULL) {
             return NGX_ERROR;
         }
 
@@ -269,9 +272,8 @@ ngx_http_range_header_filter(ngx_http_re
         content_range->key.len = sizeof("Content-Range") - 1;
         content_range->key.data = (u_char *) "Content-Range";
 
-        content_range->value.data =
-                   ngx_palloc(r->pool, sizeof("bytes */") - 1 + NGX_OFF_T_LEN);
-
+        content_range->value.data = ngx_palloc(r->pool,
+                                       sizeof("bytes */") - 1 + NGX_OFF_T_LEN);
         if (content_range->value.data == NULL) {
             return NGX_ERROR;
         }
@@ -294,7 +296,8 @@ ngx_http_range_header_filter(ngx_http_re
 
     if (r->headers_out.ranges.nelts == 1) {
 
-        if (!(content_range = ngx_list_push(&r->headers_out.headers))) {
+        content_range = ngx_list_push(&r->headers_out.headers);
+        if (content_range == NULL) {
             return NGX_ERROR;
         }
 
@@ -325,8 +328,12 @@ ngx_http_range_header_filter(ngx_http_re
 
     /* TODO: what if no content_type ?? */
 
-    ngx_http_create_ctx(r, ctx, ngx_http_range_body_filter_module,
-                        sizeof(ngx_http_range_filter_ctx_t), NGX_ERROR);
+    ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_range_filter_ctx_t));
+    if (ctx == NULL) {
+        return NGX_ERROR;
+    }
+    
+    ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module);
 
 
     len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
@@ -338,7 +345,8 @@ ngx_http_range_header_filter(ngx_http_re
         len += sizeof("; charset=") - 1 + r->headers_out.charset.len;
     }
 
-    if (!(ctx->boundary_header.data = ngx_palloc(r->pool, len))) {
+    ctx->boundary_header.data = ngx_palloc(r->pool, len);
+    if (ctx->boundary_header.data == NULL) {
         return NGX_ERROR;
     }
 
@@ -466,7 +474,8 @@ ngx_http_range_body_filter(ngx_http_requ
              * "Content-Range: bytes "
              */
 
-            if (!(b = ngx_calloc_buf(r->pool))) {
+            b = ngx_calloc_buf(r->pool);
+            if (b == NULL) {
                 return NGX_ERROR;
             }
 
@@ -474,7 +483,8 @@ ngx_http_range_body_filter(ngx_http_requ
             b->pos = ctx->boundary_header.data;
             b->last = ctx->boundary_header.data + ctx->boundary_header.len;
 
-            if (!(hcl = ngx_alloc_chain_link(r->pool))) {
+            hcl = ngx_alloc_chain_link(r->pool);
+            if (hcl == NULL) {
                 return NGX_ERROR;
             }
 
@@ -483,7 +493,8 @@ ngx_http_range_body_filter(ngx_http_requ
 
             /* "SSSS-EEEE/TTTT" CRLF CRLF */
 
-            if (!(b = ngx_calloc_buf(r->pool))) {
+            b = ngx_calloc_buf(r->pool);
+            if (b == NULL) {
                 return NGX_ERROR;
             }
 
@@ -491,7 +502,8 @@ ngx_http_range_body_filter(ngx_http_requ
             b->pos = range[i].content_range.data;
             b->last = range[i].content_range.data + range[i].content_range.len;
 
-            if (!(rcl = ngx_alloc_chain_link(r->pool))) {
+            rcl = ngx_alloc_chain_link(r->pool);
+            if (rcl == NULL) {
                 return NGX_ERROR;
             }
 
@@ -500,7 +512,8 @@ ngx_http_range_body_filter(ngx_http_requ
 
             /* the range data */
 
-            if (!(b = ngx_calloc_buf(r->pool))) {
+            b = ngx_calloc_buf(r->pool);
+            if (b == NULL) {
                 return NGX_ERROR;
             }
 
@@ -509,7 +522,8 @@ ngx_http_range_body_filter(ngx_http_requ
             b->file_last = range[i].end;
             b->file = in->buf->file;
 
-            if (!(dcl = ngx_alloc_chain_link(r->pool))) {
+            dcl = ngx_alloc_chain_link(r->pool);
+            if (dcl == NULL) {
                 return NGX_ERROR;
             }
 
@@ -523,7 +537,8 @@ ngx_http_range_body_filter(ngx_http_requ
 
         /* the last boundary CRLF "--0123456789--" CRLF  */
 
-        if (!(b = ngx_calloc_buf(r->pool))) {
+        b = ngx_calloc_buf(r->pool);
+        if (b == NULL) {
             return NGX_ERROR;
         }
 
@@ -540,7 +555,8 @@ ngx_http_range_body_filter(ngx_http_requ
         *b->last++ = '-'; *b->last++ = '-';
         *b->last++ = CR; *b->last++ = LF;
 
-        if (!(hcl = ngx_alloc_chain_link(r->pool))) {
+        hcl = ngx_alloc_chain_link(r->pool);
+        if (hcl == NULL) {
             return NGX_ERROR;
         }