nginx-0.1.35-RELEASE import

    *) Feature: the "working_directory" directive.

    *) Feature: the "port_in_redirect" directive.

    *) Bugfix: the segmentation fault was occurred if the backend response
       header was in several packets; the bug had appeared in 0.1.29.

    *) Bugfix: if more than 10 servers were configured or some server did
       not use the "listen" directive, then the segmentation fault was
       occurred on the start.

    *) Bugfix: the segmentation fault might occur if the response was
       bigger than the temporary file.

    *) Bugfix: nginx returned the 400 response on requests like
       "GET http://www.domain.com/uri HTTP/1.0"; the bug had appeared in
       0.1.28.
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 42c8211..0279579 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -319,6 +319,13 @@
       offsetof(ngx_http_core_loc_conf_t, reset_timedout_connection),
       NULL },
 
+    { ngx_string("port_in_redirect"),
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+      ngx_conf_set_flag_slot,
+      NGX_HTTP_LOC_CONF_OFFSET,
+      offsetof(ngx_http_core_loc_conf_t, port_in_redirect),
+      NULL },
+
     { ngx_string("msie_padding"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
       ngx_conf_set_flag_slot,
@@ -1113,10 +1120,10 @@
 static char *
 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
 {
-    int                         m;
     char                       *rv;
     void                       *mconf;
-    ngx_conf_t                  save;
+    ngx_uint_t                  m;
+    ngx_conf_t                  pcf;
     ngx_http_module_t          *module;
     ngx_http_conf_ctx_t        *ctx, *http_ctx;
     ngx_http_core_srv_conf_t   *cscf, **cscfp;
@@ -1189,13 +1196,13 @@
 
     /* parse inside server{} */
 
-    save = *cf;
+    pcf = *cf;
     cf->ctx = ctx;
     cf->cmd_type = NGX_HTTP_SRV_CONF;
 
     rv = ngx_conf_parse(cf, NULL);
 
-    *cf = save;
+    *cf = pcf;
 
     if (rv != NGX_CONF_OK) {
         return rv;
@@ -1622,6 +1629,7 @@
         ls->port = (getuid() == 0) ? 80 : 8000;
 #endif
         ls->family = AF_INET;
+        ls->default_server = 0;
     }
 
     if (conf->server_names.nelts == 0) {
@@ -1726,6 +1734,7 @@
     lcf->lingering_time = NGX_CONF_UNSET_MSEC;
     lcf->lingering_timeout = NGX_CONF_UNSET_MSEC;
     lcf->reset_timedout_connection = NGX_CONF_UNSET;
+    lcf->port_in_redirect = NGX_CONF_UNSET;
     lcf->msie_padding = NGX_CONF_UNSET;
 
     return lcf;
@@ -1839,6 +1848,7 @@
 
     ngx_conf_merge_value(conf->reset_timedout_connection,
                               prev->reset_timedout_connection, 0);
+    ngx_conf_merge_value(conf->port_in_redirect, prev->port_in_redirect, 1);
     ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1);
 
     if (conf->open_files == NULL) {
@@ -1857,8 +1867,8 @@
     u_char             *addr;
     ngx_int_t           port;
     ngx_uint_t          p;
-    struct hostent     *h;
     ngx_str_t          *args;
+    struct hostent     *h;
     ngx_http_listen_t  *ls;
 
     /*
@@ -1874,9 +1884,9 @@
     /* AF_INET only */
 
     ls->family = AF_INET;
-    ls->default_server = 0;
     ls->file_name = cf->conf_file->file.name;
     ls->line = cf->conf_file->line;
+    ls->default_server = 0;
 
     args = cf->args->elts;
     addr = args[1].data;