]> granicus.if.org Git - php/commitdiff
* Fix header("HTTP/..") behaviour
authorSascha Schumann <sas@php.net>
Mon, 4 Oct 1999 18:07:46 +0000 (18:07 +0000)
committerSascha Schumann <sas@php.net>
Mon, 4 Oct 1999 18:07:46 +0000 (18:07 +0000)
    * Fix leak WRT http_status_line
    * Update sapi/README
    * Remove %PHP_OUTPUT_FILES sort

ChangeLog
configure.in
main/SAPI.c
sapi/README

index 7aaa6c9ffd0a67f53a4fa8aaceaca34e74ae305a..7a598a5bc738173f204efce57560e58c54d239fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
 ?? ?? 1999, Version 4.0 Beta 3
+- Fixed header("HTTP/..."); behaviour (Sascha)
+- Improved UNIX build system. Now utilizes libtool (Sascha)
 - Upgrade some more internal functions to use new Zend function API. (Thies, 
   Zend library)
 - Fixed backwards incompatibility with ereg() (Thies)
index 035e7f12ad31f533ac5e81c8715964188230d341..e43fefb8de03462818537e0368e820b99ec1b1aa 100644 (file)
@@ -725,8 +725,6 @@ AC_SUBST(PHP_LIBS)
 AC_SUBST(PHP_SAPI)
 AC_SUBST(INSTALL_IT)
 
-PHP_OUTPUT_FILES=`echo $PHP_OUTPUT_FILES | sort`
-
 #libphp4.module 
 AC_OUTPUT([Makefile php4.spec ext/Makefile sapi/Makefile $PHP_OUTPUT_FILES
            scripts/mkextlib regex/Makefile build-defs.h], [], [
index 3b94176b87ac841ae3ac9af2aad2d74bc5468cd0..dd473890d69f378f515773d7f87e9191950cc4da 100644 (file)
@@ -198,6 +198,20 @@ SAPI_API void sapi_deactivate(SLS_D)
        }
 }
 
+static int sapi_extract_response_code(const char *header_line)
+{
+       int code = 200;
+       const char *ptr;
+
+       for (ptr = header_line; *ptr; ptr++) {
+               if (*ptr == ' ' && *(ptr + 1) != ' ') {
+                       code = atoi(ptr + 1);
+                       break;
+               }
+       }
+       
+       return code;
+}
 
 /* This function expects a *duplicated* string, that was previously emalloc()'d.
  * Pointers sent to this functions will be automatically freed by the framework.
@@ -221,6 +235,8 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
        /* Check the header for a few cases that we have special support for in SAPI */
        if (header_line_len>=5 
                && !memcmp(header_line, "HTTP/", 5)) {
+               /* filter out the response code */
+               SG(sapi_headers).http_response_code = sapi_extract_response_code(header_line);
                SG(sapi_headers).http_status_line = header_line;
                return SUCCESS;
        } else {
@@ -256,6 +272,7 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
 SAPI_API int sapi_send_headers()
 {
        int retval;
+       int ret = FAILURE;
        sapi_header_struct default_header = { SAPI_DEFAULT_CONTENT_TYPE, sizeof(SAPI_DEFAULT_CONTENT_TYPE)-1 };
        SLS_FETCH();
 
@@ -272,7 +289,7 @@ SAPI_API int sapi_send_headers()
        switch (retval) {
                case SAPI_HEADER_SENT_SUCCESSFULLY:
                        SG(headers_sent) = 1;
-                       return SUCCESS;
+                       ret = FAILURE;
                        break;
                case SAPI_HEADER_DO_SEND:
                        if (SG(sapi_headers).http_status_line) {
@@ -281,7 +298,6 @@ SAPI_API int sapi_send_headers()
                                http_status_line.header = SG(sapi_headers).http_status_line;
                                http_status_line.header_len = strlen(SG(sapi_headers).http_status_line);
                                sapi_module.send_header(&http_status_line, SG(server_context));
-                               efree(SG(sapi_headers).http_status_line);
                        }
                        if (SG(sapi_headers).send_default_content_type) {
                                sapi_module.send_header(&default_header, SG(server_context));
@@ -289,13 +305,18 @@ SAPI_API int sapi_send_headers()
                        zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) sapi_module.send_header, SG(server_context));
                        sapi_module.send_header(NULL, SG(server_context));
                        SG(headers_sent) = 1;
-                       return SUCCESS;
+                       ret = SUCCESS;
                        break;
                case SAPI_HEADER_SEND_FAILED:
-                       return FAILURE;
+                       ret = FAILURE;
                        break;
        }
-       return FAILURE;
+       
+       if (SG(sapi_headers).http_status_line) {
+               efree(SG(sapi_headers).http_status_line);
+       }
+       
+       return ret;
 }
 
 
index 7560abe64312f33e4487fb198a6195efd6222741..5ab9381733588d2f2a1f7cb27e8f08087cc18674 100644 (file)
@@ -10,8 +10,8 @@ not specified, they will default to "cgi" and "do nothing,"
 respectively.  Additionally, the following m4 macros can be used to
 influence what is created during "make":
 
-PHP_BUILD_SHARED    -- build shared target      libs/php_lib.so
-PHP_BUILD_STATIC    -- build static target      libs/php_lib.a
+PHP_BUILD_SHARED    -- build shared target      libs/libphp4.so
+PHP_BUILD_STATIC    -- build static target      libs/libphp4.a
 PHP_BUILD_PROGRAM   -- build executable         php
 
 (paths relative to top build dir)