[PATCH] Add --without-http-expect option

Josh Yudaken josh at smyte.com
Wed Aug 31 17:08:44 UTC 2016


# HG changeset patch
# User Josh Yudaken <josh at smyte.com>
# Date 1472606412 25200
#      Tue Aug 30 18:20:12 2016 -0700
# Node ID f81a22addc7fe1ca7486e932470756f4d73a3bb2
# Parent  c6372a40c2a731d8816160bf8f55a7a50050c2ac
Add --without-http-expect option

Some load balancers (specifically Google Cloud) do not support the expect
header. This adds an option to compile nginx without support.

diff -r c6372a40c2a7 -r f81a22addc7f auto/options
--- a/auto/options	Fri Aug 26 15:33:07 2016 +0300
+++ b/auto/options	Tue Aug 30 18:20:12 2016 -0700
@@ -57,6 +57,7 @@
 
 HTTP_CACHE=YES
 HTTP_CHARSET=YES
+HTTP_EXPECT=YES
 HTTP_GZIP=YES
 HTTP_SSL=NO
 HTTP_V2=NO
@@ -237,6 +238,7 @@
         --with-http_slice_module)        HTTP_SLICE=YES             ;;
 
         --without-http_charset_module)   HTTP_CHARSET=NO            ;;
+        --without-http_expect)           HTTP_EXPECT=NO             ;;
         --without-http_gzip_module)      HTTP_GZIP=NO               ;;
         --without-http_ssi_module)       HTTP_SSI=NO                ;;
         --without-http_userid_module)    HTTP_USERID=NO             ;;
diff -r c6372a40c2a7 -r f81a22addc7f src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Fri Aug 26 15:33:07 2016 +0300
+++ b/src/http/ngx_http_core_module.c	Tue Aug 30 18:20:12 2016 -0700
@@ -961,7 +961,9 @@
                       "client intended to send too large body: %O bytes",
                       r->headers_in.content_length_n);
 
+#if (NGX_HTTP_EXPECT)
         r->expect_tested = 1;
+#endif
         (void) ngx_http_discard_request_body(r);
         ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
         return NGX_OK;
@@ -2539,7 +2541,9 @@
     sr->internal = 1;
 
     sr->discard_body = r->discard_body;
+#if (NGX_HTTP_EXPECT)
     sr->expect_tested = 1;
+#endif
     sr->main_filter_need_in_memory = r->main_filter_need_in_memory;
 
     sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1;
diff -r c6372a40c2a7 -r f81a22addc7f src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c	Fri Aug 26 15:33:07 2016 +0300
+++ b/src/http/ngx_http_request.c	Tue Aug 30 18:20:12 2016 -0700
@@ -129,9 +129,11 @@
                  offsetof(ngx_http_headers_in_t, transfer_encoding),
                  ngx_http_process_header_line },
 
+#if (NGX_HTTP_EXPECT)
     { ngx_string("Expect"),
                  offsetof(ngx_http_headers_in_t, expect),
                  ngx_http_process_unique_header_line },
+#endif
 
     { ngx_string("Upgrade"),
                  offsetof(ngx_http_headers_in_t, upgrade),
diff -r c6372a40c2a7 -r f81a22addc7f src/http/ngx_http_request.h
--- a/src/http/ngx_http_request.h	Fri Aug 26 15:33:07 2016 +0300
+++ b/src/http/ngx_http_request.h	Tue Aug 30 18:20:12 2016 -0700
@@ -190,7 +190,9 @@
     ngx_table_elt_t                  *if_range;
 
     ngx_table_elt_t                  *transfer_encoding;
+#if (NGX_HTTP_EXPECT)
     ngx_table_elt_t                  *expect;
+#endif
     ngx_table_elt_t                  *upgrade;
 
 #if (NGX_HTTP_GZIP)
@@ -525,7 +527,9 @@
     unsigned                          request_complete:1;
     unsigned                          request_output:1;
     unsigned                          header_sent:1;
+#if (NGX_HTTP_EXPECT)
     unsigned                          expect_tested:1;
+#endif
     unsigned                          root_tested:1;
     unsigned                          done:1;
     unsigned                          logged:1;
diff -r c6372a40c2a7 -r f81a22addc7f src/http/ngx_http_request_body.c
--- a/src/http/ngx_http_request_body.c	Fri Aug 26 15:33:07 2016 +0300
+++ b/src/http/ngx_http_request_body.c	Tue Aug 30 18:20:12 2016 -0700
@@ -16,7 +16,9 @@
 static ngx_int_t ngx_http_read_discarded_request_body(ngx_http_request_t *r);
 static ngx_int_t ngx_http_discard_request_body_filter(ngx_http_request_t *r,
     ngx_buf_t *b);
+#if (NGX_HTTP_EXPECT)
 static ngx_int_t ngx_http_test_expect(ngx_http_request_t *r);
+#endif
 
 static ngx_int_t ngx_http_request_body_filter(ngx_http_request_t *r,
     ngx_chain_t *in);
@@ -53,10 +55,12 @@
     }
 #endif
 
+#if (NGX_HTTP_EXPECT)
     if (ngx_http_test_expect(r) != NGX_OK) {
         rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
         goto done;
     }
+#endif
 
     rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
     if (rb == NULL) {
@@ -525,9 +529,11 @@
     }
 #endif
 
+#if (NGX_HTTP_EXPECT)
     if (ngx_http_test_expect(r) != NGX_OK) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
+#endif
 
     rev = r->connection->read;
 
@@ -797,6 +803,7 @@
 }
 
 
+#if (NGX_HTTP_EXPECT)
 static ngx_int_t
 ngx_http_test_expect(ngx_http_request_t *r)
 {
@@ -837,6 +844,7 @@
 
     return NGX_ERROR;
 }
+#endif
 
 
 static ngx_int_t
diff -r c6372a40c2a7 -r f81a22addc7f src/http/ngx_http_special_response.c
--- a/src/http/ngx_http_special_response.c	Fri Aug 26 15:33:07 2016 +0300
+++ b/src/http/ngx_http_special_response.c	Tue Aug 30 18:20:12 2016 -0700
@@ -428,7 +428,9 @@
         }
     }
 
+#if (NGX_HTTP_EXPECT)
     r->expect_tested = 1;
+#endif
 
     if (ngx_http_discard_request_body(r) != NGX_OK) {
         r->keepalive = 0;
@@ -551,9 +553,11 @@
 
     overwrite = err_page->overwrite;
 
+#if (NGX_HTTP_EXPECT)
     if (overwrite && overwrite != NGX_HTTP_OK) {
         r->expect_tested = 1;
     }
+#endif
 
     if (overwrite >= 0) {
         r->err_status = overwrite;



More information about the nginx-devel mailing list