From 7aed3d51fc6377b82fa0b01c2ed14ab37c83b8b9 Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Mon, 4 Oct 1999 18:07:46 +0000 Subject: [PATCH] * Fix header("HTTP/..") behaviour * Fix leak WRT http_status_line * Update sapi/README * Remove %PHP_OUTPUT_FILES sort --- ChangeLog | 2 ++ configure.in | 2 -- main/SAPI.c | 31 ++++++++++++++++++++++++++----- sapi/README | 4 ++-- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7aaa6c9ffd..7a598a5bc7 100644 --- 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) diff --git a/configure.in b/configure.in index 035e7f12ad..e43fefb8de 100644 --- a/configure.in +++ b/configure.in @@ -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], [], [ diff --git a/main/SAPI.c b/main/SAPI.c index 3b94176b87..dd473890d6 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -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; } diff --git a/sapi/README b/sapi/README index 7560abe643..5ab9381733 100644 --- a/sapi/README +++ b/sapi/README @@ -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) -- 2.40.0