mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
@- Implemented default_charset and default_mimetype config directives (Stig)
Implemented default_charset and default_mimetype configuration directives. Started implementing ticks in PHP.
This commit is contained in:
@@ -8,13 +8,13 @@ ZEND_DIR = $(srcdir)/Zend
|
||||
SUBDIRS = Zend ext sapi $(TSRM_DIR) $(REGEX_DIR) . $(PEAR_DIR)
|
||||
|
||||
LTLIBRARY_NAME = libphp4.la
|
||||
|
||||
|
||||
LTLIBRARY_SOURCES = \
|
||||
main.c internal_functions.c snprintf.c php_sprintf.c \
|
||||
configuration-parser.c configuration-scanner.c \
|
||||
safe_mode.c fopen-wrappers.c php_realpath.c alloca.c \
|
||||
php_ini.c SAPI.c rfc1867.c dlist.c php_content_types.c strlcpy.c \
|
||||
strlcat.c mergesort.c reentrancy.c php_variables.c
|
||||
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c
|
||||
|
||||
LTLIBRARY_DEPENDENCIES = \
|
||||
Zend/libZend.la \
|
||||
@@ -35,7 +35,7 @@ PROGRAM_DEPENDENCIES = $(PROGRAM_LDADD)
|
||||
targets = $(LTLIBRARY_NAME) $(PROGRAM_NAME)
|
||||
|
||||
install_targets = install-local install-modules
|
||||
|
||||
|
||||
include $(topsrcdir)/build/rules.mk
|
||||
include $(topsrcdir)/build/library.mk
|
||||
include $(topsrcdir)/build/program.mk
|
||||
|
||||
@@ -116,7 +116,7 @@ install-modules:
|
||||
echo "installing shared modules into $(moduledir)" && \
|
||||
rm -f modules/*.la && \
|
||||
cp modules/* $(moduledir) || true
|
||||
|
||||
|
||||
include $(srcdir)/.deps
|
||||
|
||||
.PHONY: all-recursive clean-recursive install-recursive \
|
||||
|
||||
@@ -120,7 +120,7 @@ install-modules:
|
||||
echo "installing shared modules into $(moduledir)" && \
|
||||
rm -f modules/*.la && \
|
||||
cp modules/* $(moduledir) || true
|
||||
|
||||
|
||||
include $(srcdir)/.deps
|
||||
|
||||
.PHONY: all-recursive clean-recursive install-recursive \
|
||||
|
||||
20
configure.in
20
configure.in
@@ -68,14 +68,16 @@ fi
|
||||
|
||||
AM_CONFIG_HEADER(php_config.h)
|
||||
AM_MAINTAINER_MODE
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
dnl We want this one before the checks, so the checks can modify CFLAGS.
|
||||
test -z "$CFLAGS" && auto_cflags=1
|
||||
|
||||
dnl If we're using cc on HP-UX, add -Ae -D_HPUX_SOURCE [obsolete]
|
||||
dnl if test -n "$auto_cflags" && test "`uname -s 2>/dev/null`" = "HP-UX"; then
|
||||
dnl test -n "$GCC" || CFLAGS="-Ae $CFLAGS -D_HPUX_SOURCE"
|
||||
dnl fi
|
||||
dnl ## If we're using cc on HP-UX, add -Ae -D_HPUX_SOURCE [obsolete]
|
||||
dnl ## if test -n "$auto_cflags" && test "`uname -s 2>/dev/null`" = "HP-UX"
|
||||
dnl ## then
|
||||
dnl ## test -n "$GCC" || CFLAGS="-Ae $CFLAGS -D_HPUX_SOURCE"
|
||||
dnl ## fi
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_YACC
|
||||
@@ -93,10 +95,10 @@ else
|
||||
fi
|
||||
|
||||
dnl ## there has to be a better way...
|
||||
dnl## OLDLIBS=$LIBS; LIBS=""
|
||||
dnl ## OLDLIBS=$LIBS; LIBS=""
|
||||
AC_PROG_CC
|
||||
AC_AIX
|
||||
dnl## LIBS=$OLDLIBS
|
||||
dnl ## LIBS=$OLDLIBS
|
||||
|
||||
AM_PROG_CC_STDC
|
||||
|
||||
@@ -106,9 +108,9 @@ AC_PROG_LN_S
|
||||
|
||||
AM_PROG_LEX
|
||||
|
||||
dnl Make flex scanners use const if they can, even if __STDC__ is not
|
||||
dnl true, for compilers like Sun's that only set __STDC__ true in
|
||||
dnl "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
|
||||
dnl ## Make flex scanners use const if they can, even if __STDC__ is not
|
||||
dnl ## true, for compilers like Sun's that only set __STDC__ true in
|
||||
dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
|
||||
AC_C_CONST
|
||||
if test "$ac_cv_c_const" = "yes" ; then
|
||||
LEX_CFLAGS="-DYY_USE_CONST"
|
||||
|
||||
@@ -2135,3 +2135,10 @@ PHP_FUNCTION(array_multisort)
|
||||
efree(args);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
106
main/SAPI.c
106
main/SAPI.c
@@ -177,36 +177,65 @@ SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
|
||||
}
|
||||
|
||||
|
||||
SAPI_API char *sapi_get_default_content_type(SLS_D)
|
||||
{
|
||||
char *mimetype, *charset, *content_type;
|
||||
|
||||
mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE;
|
||||
charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET;
|
||||
|
||||
if (strncasecmp(mimetype, "text/", 5) == 0 && strcasecmp(charset, "none") != 0) {
|
||||
int len = strlen(mimetype) + sizeof(";charset=") + strlen(charset);
|
||||
content_type = emalloc(len);
|
||||
strlcpy(content_type, mimetype, len);
|
||||
strlcat(content_type, ";charset=", len);
|
||||
strlcat(content_type, charset, len);
|
||||
} else {
|
||||
content_type = estrdup(mimetype);
|
||||
}
|
||||
return content_type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add charset on content-type header if the MIME type starts with
|
||||
* "text/", the default_charset directive is not set to "none" and
|
||||
* there is not already a charset option in there.
|
||||
*
|
||||
* If "mimetype" is non-NULL, it should point to a pointer allocated
|
||||
* with emalloc(). If a charset is added, the string will be
|
||||
* re-allocated and the new length is returned. If mimetype is
|
||||
* unchanged, 0 is returned.
|
||||
*
|
||||
*/
|
||||
SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC)
|
||||
{
|
||||
char *charset, *newtype;
|
||||
int newlen;
|
||||
charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET;
|
||||
|
||||
if (strcasecmp(charset, "none") != 0 && strncmp(*mimetype, "text/", 5) == 0 && strstr(*mimetype, "charset=") == NULL) {
|
||||
newlen = len + (sizeof(";charset=")-1) + strlen(charset);
|
||||
newtype = emalloc(newlen + 1);
|
||||
strlcpy(newtype, *mimetype, len);
|
||||
strlcat(newtype, ";charset=", len);
|
||||
if (*mimetype != NULL) {
|
||||
efree(*mimetype);
|
||||
}
|
||||
*mimetype = newtype;
|
||||
return newlen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called from php_request_startup() for every request.
|
||||
*/
|
||||
SAPI_API void sapi_activate(SLS_D PLS_DC)
|
||||
SAPI_API void sapi_activate(SLS_D)
|
||||
{
|
||||
int len;
|
||||
|
||||
zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);
|
||||
SG(sapi_headers).send_default_content_type = 1;
|
||||
|
||||
if (PG(default_mimetype) != NULL) {
|
||||
if (strncasecmp(PG(default_mimetype), "text/", 5) == 0) {
|
||||
len = strlen(PG(default_mimetype)) + sizeof(";charset=") + strlen(PG(default_charset));
|
||||
/* add charset for text output */
|
||||
SG(sapi_headers).default_content_type = emalloc(len);
|
||||
strcpy(SG(sapi_headers).default_content_type, PG(default_mimetype));
|
||||
strlcat(SG(sapi_headers).default_content_type, ";charset=", len);
|
||||
strlcat(SG(sapi_headers).default_content_type, PG(default_charset), len);
|
||||
} else {
|
||||
/* don't add charset */
|
||||
len = strlen(PG(default_mimetype)) + 1;
|
||||
SG(sapi_headers).default_content_type = emalloc(len);
|
||||
strcpy(SG(sapi_headers).default_content_type, PG(default_mimetype));
|
||||
}
|
||||
SG(sapi_headers).default_content_type[len - 1] = '\0';
|
||||
SG(sapi_headers).default_content_type_size = len;
|
||||
} else {
|
||||
SG(sapi_headers).default_content_type = NULL;
|
||||
SG(sapi_headers).default_content_type_size = 0;
|
||||
}
|
||||
SG(sapi_headers).http_response_code = 200;
|
||||
SG(sapi_headers).http_status_line = NULL;
|
||||
SG(headers_sent) = 0;
|
||||
@@ -295,7 +324,7 @@ static int sapi_extract_response_code(const char *header_line)
|
||||
*/
|
||||
SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
|
||||
{
|
||||
int retval;
|
||||
int retval, free_header = 0;
|
||||
sapi_header_struct sapi_header;
|
||||
char *colon_offset;
|
||||
SLS_FETCH();
|
||||
@@ -329,6 +358,25 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
|
||||
if (colon_offset) {
|
||||
*colon_offset = 0;
|
||||
if (!STRCASECMP(header_line, "Content-Type")) {
|
||||
char *ptr = colon_offset, *mimetype = NULL, *newheader;
|
||||
size_t len = header_line_len - (ptr - header_line), newlen;
|
||||
while (*ptr == ' ' && *ptr != '\0') {
|
||||
ptr++;
|
||||
}
|
||||
mimetype = estrdup(ptr);
|
||||
newlen = sapi_apply_default_charset(&mimetype, len);
|
||||
if (newlen != 0) {
|
||||
newlen += sizeof("Content-type: ");
|
||||
newheader = emalloc(newlen);
|
||||
strlcpy(newheader, "Content-type: ", newlen);
|
||||
strlcpy(newheader, mimetype, newlen);
|
||||
sapi_header.header = newheader;
|
||||
sapi_header.header_len = newlen - 1;
|
||||
colon_offset = strchr(newheader, ':');
|
||||
*colon_offset = '\0';
|
||||
free_header = 1;
|
||||
}
|
||||
efree(mimetype);
|
||||
SG(sapi_headers).send_default_content_type = 0;
|
||||
} else if (!STRCASECMP(header_line, "Location")) {
|
||||
SG(sapi_headers).http_response_code = 302; /* redirect */
|
||||
@@ -350,6 +398,9 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
|
||||
if (retval & SAPI_HEADER_ADD) {
|
||||
zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_header);
|
||||
}
|
||||
if (free_header) {
|
||||
efree(sapi_header.header);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -488,3 +539,10 @@ SAPI_API char *sapi_getenv(char *name, int name_len)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -100,6 +100,8 @@ typedef struct {
|
||||
uint read_post_bytes;
|
||||
unsigned char headers_sent;
|
||||
struct stat global_stat;
|
||||
char *default_mimetype;
|
||||
char *default_charset;
|
||||
} sapi_globals_struct;
|
||||
|
||||
|
||||
@@ -142,6 +144,9 @@ SAPI_API int sapi_flush();
|
||||
SAPI_API struct stat *sapi_get_stat();
|
||||
SAPI_API char *sapi_getenv(char *name, int name_len);
|
||||
|
||||
SAPI_API char *sapi_get_default_content_type(SLS_D);
|
||||
SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC);
|
||||
|
||||
struct _sapi_module_struct {
|
||||
char *name;
|
||||
|
||||
|
||||
14
main/main.c
14
main/main.c
@@ -66,6 +66,7 @@
|
||||
#include "zend_indent.h"
|
||||
|
||||
#include "php_content_types.h"
|
||||
#include "php_ticks.h"
|
||||
|
||||
#include "SAPI.h"
|
||||
|
||||
@@ -202,8 +203,8 @@ PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateStringUnempty, default_charset, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("default_mimetype",SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateStringUnempty, default_mimetype, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateStringUnempty, default_charset, sapi_globals_struct,sapi_globals)
|
||||
STD_PHP_INI_ENTRY("default_mimetype",SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateStringUnempty, default_mimetype, sapi_globals_struct,sapi_globals)
|
||||
STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, error_log, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("extension_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals)
|
||||
@@ -801,7 +802,7 @@ int php_module_startup(sapi_module_struct *sf)
|
||||
zuf.block_interruptions = sapi_module.block_interruptions;
|
||||
zuf.unblock_interruptions = sapi_module.unblock_interruptions;
|
||||
zuf.get_ini_entry = php_get_ini_entry_for_zend;
|
||||
zuf.ticks_function = NULL;
|
||||
zuf.ticks_function = php_run_ticks;
|
||||
zend_startup(&zuf, NULL);
|
||||
|
||||
#ifdef ZTS
|
||||
@@ -851,6 +852,11 @@ int php_module_startup(sapi_module_struct *sf)
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS);
|
||||
|
||||
if (php_startup_ticks(PLS_C) == FAILURE) {
|
||||
php_printf("Unable to start PHP ticks\n");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (php_startup_internal_extensions() == FAILURE) {
|
||||
php_printf("Unable to start builtin modules\n");
|
||||
return FAILURE;
|
||||
@@ -878,6 +884,7 @@ int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals)
|
||||
void php_module_shutdown()
|
||||
{
|
||||
int module_number=0; /* for UNREGISTER_INI_ENTRIES() */
|
||||
PLS_FETCH();
|
||||
|
||||
if (!module_initialized) {
|
||||
return;
|
||||
@@ -891,6 +898,7 @@ void php_module_shutdown()
|
||||
WSACleanup();
|
||||
#endif
|
||||
|
||||
php_shutdown_ticks(PLS_C);
|
||||
sapi_flush();
|
||||
|
||||
global_lock_destroy();
|
||||
|
||||
@@ -42,6 +42,7 @@ extern PHPAPI int core_globals_id;
|
||||
extern ZEND_API struct _php_core_globals core_globals;
|
||||
#endif
|
||||
|
||||
struct _php_tick_function_entry;
|
||||
|
||||
struct _php_core_globals {
|
||||
zend_bool magic_quotes_gpc;
|
||||
@@ -83,9 +84,6 @@ struct _php_core_globals {
|
||||
char *gpc_order;
|
||||
char *variables_order;
|
||||
|
||||
char *default_mimetype;
|
||||
char *default_charset;
|
||||
|
||||
zend_bool expose_php;
|
||||
|
||||
zend_bool track_vars;
|
||||
@@ -100,6 +98,8 @@ struct _php_core_globals {
|
||||
long max_execution_time;
|
||||
|
||||
unsigned char header_is_being_sent;
|
||||
|
||||
zend_llist tick_functions;
|
||||
};
|
||||
|
||||
|
||||
|
||||
77
main/php_ticks.c
Normal file
77
main/php_ticks.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Stig Bakken <ssb@fast.no> |
|
||||
| |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "php.h"
|
||||
#include "php_ticks.h"
|
||||
|
||||
int php_startup_ticks(PLS_D)
|
||||
{
|
||||
zend_llist_init(&PG(tick_functions), sizeof(PG(tick_functions)), NULL, 1);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void php_shutdown_ticks(PLS_D)
|
||||
{
|
||||
zend_llist_destroy(&PG(tick_functions));
|
||||
}
|
||||
|
||||
static int php_compare_tick_functions(void *elem1, void *elem2)
|
||||
{
|
||||
return ((void (*)(int))elem1 == (void (*)(int))elem2);
|
||||
}
|
||||
|
||||
PHPAPI int php_add_tick_function(void (*func)(int))
|
||||
{
|
||||
PLS_FETCH();
|
||||
|
||||
zend_llist_add_element(&PG(tick_functions), func);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHPAPI int php_remove_tick_function(void (*func)(int))
|
||||
{
|
||||
PLS_FETCH();
|
||||
|
||||
zend_llist_del_element(&PG(tick_functions), func,
|
||||
(int(*)(void*,void*))php_compare_tick_functions);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void php_tick_iterator(void *data, void *arg)
|
||||
{
|
||||
void (*func)(int);
|
||||
func = (void(*)(int))data;
|
||||
func(*((int *)arg));
|
||||
}
|
||||
|
||||
void php_run_ticks(int count)
|
||||
{
|
||||
PLS_FETCH();
|
||||
|
||||
zend_llist_apply_with_argument(&PG(tick_functions), (void(*)(void*,void*))php_tick_iterator, &count);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
41
main/php_ticks.h
Normal file
41
main/php_ticks.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP version 4.0 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Stig Bakken <ssb@fast.no> |
|
||||
| |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef _PHP_TICKS_H
|
||||
#define _PHP_TICKS_H
|
||||
|
||||
struct _php_tick_function_entry {
|
||||
void (*func)(int count);
|
||||
struct _php_tick_function_entry *next;
|
||||
};
|
||||
|
||||
int php_startup_ticks(PLS_D);
|
||||
void php_shutdown_ticks(PLS_D);
|
||||
void php_run_ticks(int count);
|
||||
PHPAPI int php_add_tick_function(void (*func)(int count));
|
||||
PHPAPI int php_remove_tick_function(void (*func)(int count));
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -1,3 +1,3 @@
|
||||
/* automatically generated by configure */
|
||||
/* edit configure.in to change version number */
|
||||
#define PHP_VERSION "4.0b5-dev"
|
||||
/* edit configure.in.in to change version number */
|
||||
#define PHP_VERSION "4.0b4-dev"
|
||||
|
||||
@@ -183,6 +183,12 @@ magic_quotes_sybase = Off ; Use Sybase-style magic quotes (escape ' with '' ins
|
||||
auto_prepend_file =
|
||||
auto_append_file =
|
||||
|
||||
; As of 4.0b4, PHP always outputs a character encoding by default in
|
||||
; the Content-type: header. Set default_charset to "none" to disable
|
||||
; this. PHP's built-in default is text/html with the iso-8859-1
|
||||
; charset.
|
||||
;default_mimetype = "text/html"
|
||||
;default_charset = "iso-8859-1"
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Paths and Directories ;
|
||||
@@ -386,3 +392,6 @@ mssql.compatability_mode = Off ; compatability mode with old versions of PHP 3.0
|
||||
;assert.callback = 0 ; user-function to be called if an assertion fails.
|
||||
;assert.quiet_eval = 0 ; eval the expression with current error_reporting(). set to true if you want error_reporting(0) around the eval().
|
||||
|
||||
; Local Variables:
|
||||
; tab-width: 4
|
||||
; End:
|
||||
|
||||
@@ -399,6 +399,22 @@ static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *php_apache_get_default_mimetype(request_rec *r SLS_DC)
|
||||
{
|
||||
|
||||
char *mimetype;
|
||||
if (SG(default_mimetype) || SG(default_charset)) {
|
||||
/* Assume output will be of the default MIME type. Individual
|
||||
scripts may change this later. */
|
||||
char *tmpmimetype;
|
||||
tmpmimetype = sapi_get_default_content_type(SLS_C);
|
||||
mimetype = pstrdup(r->pool, tmpmimetype);
|
||||
efree(tmpmimetype);
|
||||
} else {
|
||||
mimetype = SAPI_DEFAULT_CONTENT_TYPE;
|
||||
}
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
int send_php(request_rec *r, int display_source_mode, char *filename)
|
||||
{
|
||||
@@ -428,7 +444,7 @@ int send_php(request_rec *r, int display_source_mode, char *filename)
|
||||
* directive, then decline to handle this request
|
||||
*/
|
||||
if (!php_apache_info.engine) {
|
||||
r->content_type = SAPI_DEFAULT_CONTENT_TYPE; /* XXX FIXME use default_{mimetype|charset} directives */
|
||||
r->content_type = php_apache_get_default_mimetype(r SLS_CC);
|
||||
r->allowed |= (1 << METHODS) - 1;
|
||||
return DECLINED;
|
||||
}
|
||||
@@ -458,9 +474,9 @@ int send_php(request_rec *r, int display_source_mode, char *filename)
|
||||
set_etag(r);
|
||||
#endif
|
||||
}
|
||||
/* Assume output will be HTML. Individual scripts may change this
|
||||
further down the line */
|
||||
r->content_type = SAPI_DEFAULT_CONTENT_TYPE; /* XXX FIXME use default_{mimetype|charset} directives */
|
||||
/* Assume output will be of the default MIME type. Individual
|
||||
scripts may change this later in the request. */
|
||||
r->content_type = php_apache_get_default_mimetype(r SLS_CC);
|
||||
|
||||
/* Init timeout */
|
||||
hard_timeout("send", r);
|
||||
|
||||
Reference in New Issue
Block a user