rasmus          Mon Mar 14 14:25:40 2005 EDT

  Modified files:              
    /php-src/main       SAPI.c SAPI.h 
    /php-src/sapi/aolserver     aolserver.c 
    /php-src/sapi/apache        mod_php5.c 
    /php-src/sapi/apache2filter sapi_apache2.c 
    /php-src/sapi/apache2handler        sapi_apache2.c 
    /php-src/sapi/apache_hooks  mod_php5.c 
    /php-src/sapi/cgi   cgi_main.c 
    /php-src/sapi/thttpd        thttpd.c 
    /php-src/sapi/tux   php_tux.c 
  Log:
  Fix for bug #32263
  This adds proto_num to request_info.  It is defaulted to HTTP 1.0 (1000)
  such that it has a valid value even if the underlying sapi doesn't set it
  correctly.  It is then used to determine if a 302 or a 303 should be sent
  on a Location redirect.  Any non GET/HEAD HTTP 1.1 redirect will get a 303
  instead of a 302 to be compatible with the HTTP spec.
  
  
http://cvs.php.net/diff.php/php-src/main/SAPI.c?r1=1.198&r2=1.199&ty=u
Index: php-src/main/SAPI.c
diff -u php-src/main/SAPI.c:1.198 php-src/main/SAPI.c:1.199
--- php-src/main/SAPI.c:1.198   Sat Mar 12 07:03:50 2005
+++ php-src/main/SAPI.c Mon Mar 14 14:25:37 2005
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: SAPI.c,v 1.198 2005/03/12 12:03:50 andrey Exp $ */
+/* $Id: SAPI.c,v 1.199 2005/03/14 19:25:37 rasmus Exp $ */
 
 #include <ctype.h>
 #include <sys/stat.h>
@@ -346,6 +346,7 @@
        SG(request_info).current_user_length = 0;
        SG(request_info).no_headers = 0;
        SG(request_info).post_entry = NULL;
+       SG(request_info).proto_num = 1000; /* Default to HTTP 1.0 */
        SG(global_request_time) = 0;
 
        /* It's possible to override this general case in the activate() 
callback, if
@@ -608,7 +609,14 @@
                                        SG(sapi_headers).http_response_code > 
307) &&
                                        SG(sapi_headers).http_response_code != 
201) {
                                        /* Return a Found Redirect if one is 
not already specified */
-                                       sapi_update_response_code(302 
TSRMLS_CC);
+                                       if(SG(request_info).proto_num > 1000 && 
+                                          SG(request_info).request_method && 
+                                          
strcmp(SG(request_info).request_method, "HEAD") &&
+                                          
strcmp(SG(request_info).request_method, "GET")) {
+                                               sapi_update_response_code(303 
TSRMLS_CC);
+                                       } else {
+                                               sapi_update_response_code(302 
TSRMLS_CC);
+                                       }
                                }
                        } else if (!STRCASECMP(header_line, 
"WWW-Authenticate")) { /* HTTP Authentication */
 
http://cvs.php.net/diff.php/php-src/main/SAPI.h?r1=1.111&r2=1.112&ty=u
Index: php-src/main/SAPI.h
diff -u php-src/main/SAPI.h:1.111 php-src/main/SAPI.h:1.112
--- php-src/main/SAPI.h:1.111   Mon Feb 21 10:14:02 2005
+++ php-src/main/SAPI.h Mon Mar 14 14:25:37 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: SAPI.h,v 1.111 2005/02/21 15:14:02 moriyoshi Exp $ */
+/* $Id: SAPI.h,v 1.112 2005/03/14 19:25:37 rasmus Exp $ */
 
 #ifndef SAPI_H
 #define SAPI_H
@@ -109,6 +109,7 @@
     /* this is necessary for CLI module */
     int argc;
     char **argv;
+       int proto_num;
 } sapi_request_info;
 
 
http://cvs.php.net/diff.php/php-src/sapi/aolserver/aolserver.c?r1=1.78&r2=1.79&ty=u
Index: php-src/sapi/aolserver/aolserver.c
diff -u php-src/sapi/aolserver/aolserver.c:1.78 
php-src/sapi/aolserver/aolserver.c:1.79
--- php-src/sapi/aolserver/aolserver.c:1.78     Mon Dec 20 14:33:35 2004
+++ php-src/sapi/aolserver/aolserver.c  Mon Mar 14 14:25:38 2005
@@ -22,7 +22,7 @@
  * - CGI/1.1 conformance
  */
 
-/* $Id: aolserver.c,v 1.78 2004/12/20 19:33:35 rasmus Exp $ */
+/* $Id: aolserver.c,v 1.79 2005/03/14 19:25:38 rasmus Exp $ */
 
 /* conflict between PHP and AOLserver headers */
 #define Debug php_Debug
@@ -205,7 +205,7 @@
        int i;
        
        php_info_print_table_start();
-       php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 
1.78 2004/12/20 19:33:35 rasmus Exp $");
+       php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 
1.79 2005/03/14 19:25:38 rasmus Exp $");
        php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
        php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
        php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -444,6 +444,8 @@
        root = Ns_PageRoot(server);
        SG(request_info).request_uri = strdup(SG(request_info).path_translated 
+ strlen(root));
        SG(request_info).request_method = NSG(conn)->request->method;
+       if(NSG(conn)->request->version > 1.0) SG(request_info).proto_num = 1001;
+       else SG(request_info).proto_num = 1000;
        SG(request_info).content_length = Ns_ConnContentLength(NSG(conn));
        index = Ns_SetIFind(NSG(conn)->headers, "content-type");
        SG(request_info).content_type = index == -1 ? NULL : 
http://cvs.php.net/diff.php/php-src/sapi/apache/mod_php5.c?r1=1.12&r2=1.13&ty=u
Index: php-src/sapi/apache/mod_php5.c
diff -u php-src/sapi/apache/mod_php5.c:1.12 php-src/sapi/apache/mod_php5.c:1.13
--- php-src/sapi/apache/mod_php5.c:1.12 Tue Aug 10 13:40:00 2004
+++ php-src/sapi/apache/mod_php5.c      Mon Mar 14 14:25:38 2005
@@ -17,7 +17,7 @@
    | PHP 4.0 patches by Zeev Suraski <[EMAIL PROTECTED]>                      |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php5.c,v 1.12 2004/08/10 17:40:00 rasmus Exp $ */
+/* $Id: mod_php5.c,v 1.13 2005/03/14 19:25:38 rasmus Exp $ */
 
 #include "php_apache_http.h"
 #include "http_conf_globals.h"
@@ -484,6 +484,7 @@
        SG(request_info).content_type = (char *) table_get(r->subprocess_env, 
"CONTENT_TYPE");
        SG(request_info).content_length = (content_length ? 
atoi(content_length) : 0);
        SG(sapi_headers).http_response_code = r->status;
+       SG(request_info).proto_num = r->proto_num;
 
        if (r->headers_in) {
                authorization = table_get(r->headers_in, "Authorization");
http://cvs.php.net/diff.php/php-src/sapi/apache2filter/sapi_apache2.c?r1=1.132&r2=1.133&ty=u
Index: php-src/sapi/apache2filter/sapi_apache2.c
diff -u php-src/sapi/apache2filter/sapi_apache2.c:1.132 
php-src/sapi/apache2filter/sapi_apache2.c:1.133
--- php-src/sapi/apache2filter/sapi_apache2.c:1.132     Fri Jan  7 01:28:08 2005
+++ php-src/sapi/apache2filter/sapi_apache2.c   Mon Mar 14 14:25:38 2005
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c,v 1.132 2005/01/07 06:28:08 sniper Exp $ */
+/* $Id: sapi_apache2.c,v 1.133 2005/03/14 19:25:38 rasmus Exp $ */
 
 #include <fcntl.h>
 
@@ -397,6 +397,7 @@
 #define safe_strdup(x) ((x)?strdup((x)):NULL)  
        SG(request_info).query_string = safe_strdup(f->r->args);
        SG(request_info).request_method = f->r->method;
+       SG(request_info).proto_num = f->r->proto_num;
        SG(request_info).request_uri = safe_strdup(f->r->uri);
        SG(request_info).path_translated = safe_strdup(f->r->filename);
        f->r->no_local_copy = 1;
http://cvs.php.net/diff.php/php-src/sapi/apache2handler/sapi_apache2.c?r1=1.52&r2=1.53&ty=u
Index: php-src/sapi/apache2handler/sapi_apache2.c
diff -u php-src/sapi/apache2handler/sapi_apache2.c:1.52 
php-src/sapi/apache2handler/sapi_apache2.c:1.53
--- php-src/sapi/apache2handler/sapi_apache2.c:1.52     Thu Mar 10 06:09:32 2005
+++ php-src/sapi/apache2handler/sapi_apache2.c  Mon Mar 14 14:25:38 2005
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c,v 1.52 2005/03/10 11:09:32 jorton Exp $ */
+/* $Id: sapi_apache2.c,v 1.53 2005/03/14 19:25:38 rasmus Exp $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
@@ -418,6 +418,7 @@
        SG(request_info).content_type = apr_table_get(r->headers_in, 
"Content-Type");
        SG(request_info).query_string = apr_pstrdup(r->pool, r->args);
        SG(request_info).request_method = r->method;
+       SG(request_info).proto_num = r->proto_num;
        SG(request_info).request_uri = apr_pstrdup(r->pool, r->uri);
        SG(request_info).path_translated = apr_pstrdup(r->pool, r->filename);
        r->no_local_copy = 1;
http://cvs.php.net/diff.php/php-src/sapi/apache_hooks/mod_php5.c?r1=1.6&r2=1.7&ty=u
Index: php-src/sapi/apache_hooks/mod_php5.c
diff -u php-src/sapi/apache_hooks/mod_php5.c:1.6 
php-src/sapi/apache_hooks/mod_php5.c:1.7
--- php-src/sapi/apache_hooks/mod_php5.c:1.6    Mon Dec 20 14:33:36 2004
+++ php-src/sapi/apache_hooks/mod_php5.c        Mon Mar 14 14:25:38 2005
@@ -17,7 +17,7 @@
    | PHP 4.0 patches by Zeev Suraski <[EMAIL PROTECTED]>                       
                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php5.c,v 1.6 2004/12/20 19:33:36 rasmus Exp $ */
+/* $Id: mod_php5.c,v 1.7 2005/03/14 19:25:38 rasmus Exp $ */
 
 #include "php_apache_http.h"
 
@@ -571,6 +571,7 @@
        SG(request_info).path_translated = r->filename;
        SG(request_info).request_uri = r->uri;
        SG(request_info).request_method = (char *)r->method;
+       SG(request_info).proto_num = r->proto_num;
        SG(request_info).content_type = (char *) table_get(r->subprocess_env, 
"CONTENT_TYPE");
        SG(request_info).content_length = (content_length ? 
atoi(content_length) : 0);
        SG(sapi_headers).http_response_code = r->status;
http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.261&r2=1.262&ty=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.261 php-src/sapi/cgi/cgi_main.c:1.262
--- php-src/sapi/cgi/cgi_main.c:1.261   Thu Feb 10 21:03:51 2005
+++ php-src/sapi/cgi/cgi_main.c Mon Mar 14 14:25:39 2005
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c,v 1.261 2005/02/11 02:03:51 sniper Exp $ */
+/* $Id: cgi_main.c,v 1.262 2005/03/14 19:25:39 rasmus Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -676,6 +676,7 @@
        /* initialize the defaults */
        SG(request_info).path_translated = NULL;
        SG(request_info).request_method = NULL;
+       SG(request_info).proto_num = 1000;
        SG(request_info).query_string = NULL;
        SG(request_info).request_uri = NULL;
        SG(request_info).content_type = NULL;
@@ -862,6 +863,7 @@
                }
 #endif
                SG(request_info).request_method = 
sapi_cgibin_getenv("REQUEST_METHOD",0 TSRMLS_CC);
+               /* FIXME - Work out proto_num here */
                SG(request_info).query_string = 
sapi_cgibin_getenv("QUERY_STRING",0 TSRMLS_CC);
                /* some server configurations allow '..' to slip through in the
                   translated path.   We'll just refuse to handle such a path. 
*/
http://cvs.php.net/diff.php/php-src/sapi/thttpd/thttpd.c?r1=1.93&r2=1.94&ty=u
Index: php-src/sapi/thttpd/thttpd.c
diff -u php-src/sapi/thttpd/thttpd.c:1.93 php-src/sapi/thttpd/thttpd.c:1.94
--- php-src/sapi/thttpd/thttpd.c:1.93   Mon Dec 20 14:33:40 2004
+++ php-src/sapi/thttpd/thttpd.c        Mon Mar 14 14:25:39 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: thttpd.c,v 1.93 2004/12/20 19:33:40 rasmus Exp $ */
+/* $Id: thttpd.c,v 1.94 2005/03/14 19:25:39 rasmus Exp $ */
 
 #include "php.h"
 #include "SAPI.h"
@@ -451,6 +451,8 @@
        smart_str_0(&s);
        SG(request_info).request_uri = s.c;
        SG(request_info).request_method = httpd_method_str(TG(hc)->method);
+       if (TG(hc)->one_one) SG(request_info).proto_num = 1001;
+       else SG(request_info).proto_num = 1000;
        SG(sapi_headers).http_response_code = 200;
        if (TG(hc)->contenttype)
                SG(request_info).content_type = strdup(TG(hc)->contenttype);
http://cvs.php.net/diff.php/php-src/sapi/tux/php_tux.c?r1=1.24&r2=1.25&ty=u
Index: php-src/sapi/tux/php_tux.c
diff -u php-src/sapi/tux/php_tux.c:1.24 php-src/sapi/tux/php_tux.c:1.25
--- php-src/sapi/tux/php_tux.c:1.24     Mon Dec 20 14:33:40 2004
+++ php-src/sapi/tux/php_tux.c  Mon Mar 14 14:25:39 2005
@@ -336,6 +336,8 @@
        smart_str_0(&s);
        SG(request_info).request_uri = s.c;
        SG(request_info).request_method = CGI_REQUEST_METHOD(TG(req));
+       if(TG(req)->http_version == HTTP_1_1) SG(request_info).proto_num = 1001;
+       else SG(request_info).proto_num = 1000;
        SG(sapi_headers).http_response_code = 200;
        SG(request_info).content_type = TG(req)->content_type;
        SG(request_info).content_length = 0; /* TG(req)->contentlength; */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to