1999-07-16 21:13:16 +08:00
|
|
|
/*
|
1999-05-07 05:58:49 +08:00
|
|
|
+----------------------------------------------------------------------+
|
1999-07-16 21:13:16 +08:00
|
|
|
| PHP version 4.0 |
|
1999-05-07 05:58:49 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2000-01-01 09:32:05 +08:00
|
|
|
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
|
1999-05-07 05:58:49 +08:00
|
|
|
+----------------------------------------------------------------------+
|
1999-07-16 21:13:16 +08:00
|
|
|
| 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. |
|
1999-05-07 05:58:49 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2000-02-11 04:13:08 +08:00
|
|
|
| Original design: Shane Caraveo <shane@caraveo.com> |
|
1999-05-07 05:58:49 +08:00
|
|
|
| Authors: Andi Gutmans <andi@zend.com> |
|
|
|
|
| Zeev Suraski <zeev@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
1999-05-30 00:20:55 +08:00
|
|
|
#include <ctype.h>
|
2000-02-11 01:26:57 +08:00
|
|
|
#include <sys/stat.h>
|
1999-05-07 05:58:49 +08:00
|
|
|
|
1999-09-06 03:04:40 +08:00
|
|
|
#include "php.h"
|
1999-04-26 03:36:57 +08:00
|
|
|
#include "SAPI.h"
|
1999-04-26 22:00:49 +08:00
|
|
|
#ifdef ZTS
|
1999-04-26 03:36:57 +08:00
|
|
|
#include "TSRM.h"
|
1999-04-26 22:00:49 +08:00
|
|
|
#endif
|
1999-04-26 03:36:57 +08:00
|
|
|
|
1999-05-26 06:28:24 +08:00
|
|
|
#include "rfc1867.h"
|
|
|
|
|
2000-02-11 23:59:30 +08:00
|
|
|
#ifdef PHP_WIN32
|
1999-05-06 02:25:20 +08:00
|
|
|
#define STRCASECMP stricmp
|
|
|
|
#else
|
|
|
|
#define STRCASECMP strcasecmp
|
|
|
|
#endif
|
|
|
|
|
1999-04-26 03:36:57 +08:00
|
|
|
|
1999-06-13 01:50:39 +08:00
|
|
|
SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
|
1999-05-26 05:14:54 +08:00
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
static sapi_post_entry supported_post_entries[] = {
|
1999-10-06 13:26:25 +08:00
|
|
|
#if HAVE_FDFLIB
|
|
|
|
{ "application/vnd.fdf", sizeof("application/vnd.fdf")-1, sapi_read_standard_form_data },
|
|
|
|
#endif
|
1999-05-26 05:14:54 +08:00
|
|
|
{ NULL, 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static HashTable known_post_content_types;
|
|
|
|
|
1999-05-07 05:58:49 +08:00
|
|
|
SAPI_API void (*sapi_error)(int error_type, const char *message, ...);
|
|
|
|
|
|
|
|
|
1999-04-26 03:36:57 +08:00
|
|
|
#ifdef ZTS
|
1999-04-26 22:00:49 +08:00
|
|
|
SAPI_API int sapi_globals_id;
|
1999-04-27 01:26:37 +08:00
|
|
|
#else
|
|
|
|
sapi_globals_struct sapi_globals;
|
1999-04-26 03:36:57 +08:00
|
|
|
#endif
|
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
|
1999-05-07 05:58:49 +08:00
|
|
|
/* True globals (no need for thread safety) */
|
1999-05-03 02:07:41 +08:00
|
|
|
sapi_module_struct sapi_module;
|
1999-05-07 05:58:49 +08:00
|
|
|
SAPI_API void (*sapi_error)(int error_type, const char *message, ...);
|
1999-04-26 03:36:57 +08:00
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
|
1999-05-03 02:07:41 +08:00
|
|
|
SAPI_API void sapi_startup(sapi_module_struct *sf)
|
1999-04-26 03:36:57 +08:00
|
|
|
{
|
1999-05-03 02:07:41 +08:00
|
|
|
sapi_module = *sf;
|
1999-05-26 05:14:54 +08:00
|
|
|
zend_hash_init(&known_post_content_types, 5, NULL, NULL, 1);
|
1999-09-17 07:18:15 +08:00
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
sapi_register_post_entries(supported_post_entries);
|
1999-09-17 07:18:15 +08:00
|
|
|
|
1999-04-26 03:36:57 +08:00
|
|
|
#ifdef ZTS
|
|
|
|
sapi_globals_id = ts_allocate_id(sizeof(sapi_globals_struct), NULL, NULL);
|
|
|
|
#endif
|
2000-01-06 03:25:19 +08:00
|
|
|
reentrancy_startup();
|
1999-05-06 02:25:20 +08:00
|
|
|
|
1999-12-08 04:49:01 +08:00
|
|
|
php_global_startup_internal_extensions();
|
1999-09-04 01:46:39 +08:00
|
|
|
}
|
1999-05-06 02:25:20 +08:00
|
|
|
|
1999-12-06 00:25:32 +08:00
|
|
|
SAPI_API void sapi_shutdown(void)
|
1999-05-29 06:41:48 +08:00
|
|
|
{
|
2000-01-06 03:25:19 +08:00
|
|
|
reentrancy_shutdown();
|
1999-12-08 04:49:01 +08:00
|
|
|
php_global_shutdown_internal_extensions();
|
1999-05-29 06:41:48 +08:00
|
|
|
zend_hash_destroy(&known_post_content_types);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-10 20:38:20 +08:00
|
|
|
SAPI_API void sapi_free_header(sapi_header_struct *sapi_header)
|
1999-05-06 02:25:20 +08:00
|
|
|
{
|
|
|
|
efree(sapi_header->header);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
SAPI_API void sapi_handle_post(void *arg SLS_DC)
|
|
|
|
{
|
|
|
|
if (SG(request_info).post_entry) {
|
|
|
|
SG(request_info).post_entry->post_handler(SG(request_info).content_type_dup, arg SLS_CC);
|
|
|
|
efree(SG(request_info).post_data);
|
|
|
|
efree(SG(request_info).content_type_dup);
|
|
|
|
SG(request_info).content_type_dup = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-10 02:40:59 +08:00
|
|
|
static void sapi_read_post_data(SLS_D)
|
1999-05-26 05:14:54 +08:00
|
|
|
{
|
2000-02-18 04:23:59 +08:00
|
|
|
sapi_post_entry *post_entry;
|
1999-05-26 05:14:54 +08:00
|
|
|
uint content_type_length = strlen(SG(request_info).content_type);
|
|
|
|
char *content_type = estrndup(SG(request_info).content_type, content_type_length);
|
1999-05-26 06:28:24 +08:00
|
|
|
char *p;
|
|
|
|
char oldchar=0;
|
2000-02-18 04:23:59 +08:00
|
|
|
void (*post_reader_func)(SLS_D);
|
1999-09-17 07:18:15 +08:00
|
|
|
|
1999-05-26 06:28:24 +08:00
|
|
|
|
|
|
|
/* dedicated implementation for increased performance:
|
|
|
|
* - Make the content type lowercase
|
|
|
|
* - Trim descriptive data, stay with the content-type only
|
|
|
|
*/
|
|
|
|
for (p=content_type; p<content_type+content_type_length; p++) {
|
|
|
|
switch (*p) {
|
|
|
|
case ';':
|
|
|
|
case ',':
|
|
|
|
case ' ':
|
|
|
|
content_type_length = p-content_type;
|
|
|
|
oldchar = *p;
|
|
|
|
*p = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*p = tolower(*p);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-05-26 05:14:54 +08:00
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
if (zend_hash_find(&known_post_content_types, content_type, content_type_length+1, (void **) &post_entry)==SUCCESS) {
|
|
|
|
SG(request_info).post_entry = post_entry;
|
|
|
|
post_reader_func = post_entry->post_reader;
|
1999-09-17 07:18:15 +08:00
|
|
|
} else {
|
|
|
|
if (!sapi_module.default_post_reader) {
|
|
|
|
sapi_module.sapi_error(E_COMPILE_ERROR, "Unsupported content type: '%s'", content_type);
|
|
|
|
return;
|
|
|
|
}
|
2000-02-18 04:23:59 +08:00
|
|
|
SG(request_info).post_entry = NULL;
|
1999-09-17 07:18:15 +08:00
|
|
|
post_reader_func = sapi_module.default_post_reader;
|
1999-05-26 05:14:54 +08:00
|
|
|
}
|
1999-05-26 06:28:24 +08:00
|
|
|
if (oldchar) {
|
|
|
|
*(p-1) = oldchar;
|
|
|
|
}
|
2000-02-18 04:23:59 +08:00
|
|
|
post_reader_func(SLS_C);
|
|
|
|
SG(request_info).content_type_dup = content_type;
|
1999-05-26 05:14:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-06-13 01:50:39 +08:00
|
|
|
SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
|
1999-05-10 02:40:59 +08:00
|
|
|
{
|
|
|
|
int read_bytes, total_read_bytes=0;
|
|
|
|
int allocated_bytes=SAPI_POST_BLOCK_SIZE+1;
|
|
|
|
|
|
|
|
SG(request_info).post_data = emalloc(allocated_bytes);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
read_bytes = sapi_module.read_post(SG(request_info).post_data+total_read_bytes, SAPI_POST_BLOCK_SIZE SLS_CC);
|
|
|
|
if (read_bytes<=0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
total_read_bytes += read_bytes;
|
|
|
|
if (read_bytes < SAPI_POST_BLOCK_SIZE) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (total_read_bytes+SAPI_POST_BLOCK_SIZE >= allocated_bytes) {
|
|
|
|
allocated_bytes = total_read_bytes+SAPI_POST_BLOCK_SIZE+1;
|
|
|
|
SG(request_info).post_data = erealloc(SG(request_info).post_data, allocated_bytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SG(request_info).post_data[total_read_bytes] = 0; /* terminating NULL */
|
1999-09-17 07:18:15 +08:00
|
|
|
SG(request_info).post_data_length = total_read_bytes;
|
1999-05-10 02:40:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
SAPI_API void sapi_activate(SLS_D)
|
|
|
|
{
|
|
|
|
zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);
|
1999-05-09 16:48:05 +08:00
|
|
|
SG(sapi_headers).send_default_content_type = 1;
|
1999-05-06 02:25:20 +08:00
|
|
|
SG(sapi_headers).http_response_code = 200;
|
1999-05-12 04:38:16 +08:00
|
|
|
SG(sapi_headers).http_status_line = NULL;
|
1999-05-06 03:53:15 +08:00
|
|
|
SG(headers_sent) = 0;
|
1999-05-10 02:40:59 +08:00
|
|
|
SG(read_post_bytes) = 0;
|
1999-05-12 04:38:16 +08:00
|
|
|
SG(request_info).post_data = NULL;
|
2000-02-11 04:13:08 +08:00
|
|
|
SG(request_info).current_user = NULL;
|
|
|
|
SG(request_info).current_user_length = 0;
|
1999-05-26 05:14:54 +08:00
|
|
|
|
|
|
|
if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) {
|
|
|
|
SG(request_info).headers_only = 1;
|
|
|
|
} else {
|
|
|
|
SG(request_info).headers_only = 0;
|
|
|
|
}
|
|
|
|
|
1999-05-09 16:48:05 +08:00
|
|
|
if (SG(server_context)) {
|
1999-05-11 03:48:23 +08:00
|
|
|
if (SG(request_info).request_method
|
|
|
|
&& !strcmp(SG(request_info).request_method, "POST")) {
|
1999-05-29 06:41:48 +08:00
|
|
|
if (!SG(request_info).content_type) {
|
|
|
|
sapi_module.sapi_error(E_COMPILE_ERROR, "No content-type in POST request");
|
|
|
|
}
|
1999-05-10 04:58:26 +08:00
|
|
|
sapi_read_post_data(SLS_C);
|
|
|
|
}
|
1999-05-09 16:48:05 +08:00
|
|
|
SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C);
|
2000-02-11 03:22:36 +08:00
|
|
|
if (sapi_module.activate) {
|
|
|
|
sapi_module.activate(SLS_C);
|
|
|
|
}
|
2000-02-11 00:44:59 +08:00
|
|
|
}
|
1999-05-06 02:25:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SAPI_API void sapi_deactivate(SLS_D)
|
|
|
|
{
|
|
|
|
zend_llist_destroy(&SG(sapi_headers).headers);
|
1999-05-12 04:38:16 +08:00
|
|
|
if (SG(request_info).post_data) {
|
1999-05-09 16:48:05 +08:00
|
|
|
efree(SG(request_info).post_data);
|
1999-05-06 05:29:26 +08:00
|
|
|
}
|
2000-02-16 07:31:10 +08:00
|
|
|
if (SG(request_info).auth_user) {
|
|
|
|
efree(SG(request_info).auth_user);
|
|
|
|
}
|
|
|
|
if (SG(request_info).auth_password) {
|
|
|
|
efree(SG(request_info).auth_password);
|
|
|
|
}
|
2000-02-18 04:23:59 +08:00
|
|
|
if (SG(request_info).content_type_dup) {
|
|
|
|
efree(SG(request_info).content_type_dup);
|
|
|
|
}
|
2000-02-11 04:13:08 +08:00
|
|
|
if (SG(request_info).current_user) {
|
|
|
|
efree(SG(request_info).current_user);
|
|
|
|
}
|
2000-02-11 00:44:59 +08:00
|
|
|
if (sapi_module.deactivate) {
|
|
|
|
sapi_module.deactivate(SLS_C);
|
|
|
|
}
|
1999-05-06 02:25:20 +08:00
|
|
|
}
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
|
|
|
|
SAPI_API void sapi_initialize_empty_request(SLS_D)
|
|
|
|
{
|
|
|
|
SG(server_context) = NULL;
|
|
|
|
SG(request_info).request_method = NULL;
|
|
|
|
SG(request_info).auth_user = SG(request_info).auth_password = NULL;
|
|
|
|
SG(request_info).content_type_dup = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-05 02:07:46 +08:00
|
|
|
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;
|
|
|
|
}
|
1999-05-06 02:25:20 +08:00
|
|
|
|
|
|
|
/* This function expects a *duplicated* string, that was previously emalloc()'d.
|
|
|
|
* Pointers sent to this functions will be automatically freed by the framework.
|
|
|
|
*/
|
1999-05-07 05:58:49 +08:00
|
|
|
SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
|
1999-05-06 02:25:20 +08:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
sapi_header_struct sapi_header;
|
1999-05-12 02:36:35 +08:00
|
|
|
char *colon_offset;
|
1999-05-06 02:25:20 +08:00
|
|
|
SLS_FETCH();
|
|
|
|
|
1999-05-07 05:58:49 +08:00
|
|
|
if (SG(headers_sent)) {
|
2000-02-04 22:54:30 +08:00
|
|
|
char *output_start_filename = php_get_output_start_filename();
|
|
|
|
int output_start_lineno = php_get_output_start_lineno();
|
|
|
|
|
|
|
|
if (output_start_filename) {
|
|
|
|
sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent by (output started at %s:%d)",
|
|
|
|
output_start_filename, output_start_lineno);
|
|
|
|
} else {
|
|
|
|
sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent");
|
|
|
|
}
|
1999-05-07 05:58:49 +08:00
|
|
|
efree(header_line);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sapi_header.header = header_line;
|
1999-05-06 02:25:20 +08:00
|
|
|
sapi_header.header_len = header_line_len;
|
|
|
|
|
1999-05-12 04:38:16 +08:00
|
|
|
/* Check the header for a few cases that we have special support for in SAPI */
|
1999-08-10 01:40:28 +08:00
|
|
|
if (header_line_len>=5
|
|
|
|
&& !memcmp(header_line, "HTTP/", 5)) {
|
1999-10-05 02:07:46 +08:00
|
|
|
/* filter out the response code */
|
|
|
|
SG(sapi_headers).http_response_code = sapi_extract_response_code(header_line);
|
1999-05-12 04:38:16 +08:00
|
|
|
SG(sapi_headers).http_status_line = header_line;
|
1999-08-10 01:40:28 +08:00
|
|
|
return SUCCESS;
|
1999-05-12 04:38:16 +08:00
|
|
|
} else {
|
|
|
|
colon_offset = strchr(header_line, ':');
|
|
|
|
if (colon_offset) {
|
|
|
|
*colon_offset = 0;
|
|
|
|
if (!STRCASECMP(header_line, "Content-Type")) {
|
|
|
|
SG(sapi_headers).send_default_content_type = 0;
|
|
|
|
} else if (!STRCASECMP(header_line, "Location")) {
|
|
|
|
SG(sapi_headers).http_response_code = 302; /* redirect */
|
|
|
|
} else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */
|
|
|
|
SG(sapi_headers).http_response_code = 401; /* authentication-required */
|
|
|
|
}
|
|
|
|
*colon_offset = ':';
|
1999-05-12 02:36:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-06 03:53:15 +08:00
|
|
|
if (sapi_module.header_handler) {
|
1999-05-09 16:48:05 +08:00
|
|
|
retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) SLS_CC);
|
1999-05-06 03:53:15 +08:00
|
|
|
} else {
|
|
|
|
retval = SAPI_HEADER_ADD;
|
|
|
|
}
|
1999-05-06 02:25:20 +08:00
|
|
|
if (retval & SAPI_HEADER_DELETE_ALL) {
|
|
|
|
zend_llist_clean(&SG(sapi_headers).headers);
|
|
|
|
}
|
|
|
|
if (retval & SAPI_HEADER_ADD) {
|
|
|
|
zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_header);
|
|
|
|
}
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SAPI_API int sapi_send_headers()
|
|
|
|
{
|
1999-05-06 03:53:15 +08:00
|
|
|
int retval;
|
1999-10-05 02:07:46 +08:00
|
|
|
int ret = FAILURE;
|
1999-05-06 05:47:04 +08:00
|
|
|
sapi_header_struct default_header = { SAPI_DEFAULT_CONTENT_TYPE, sizeof(SAPI_DEFAULT_CONTENT_TYPE)-1 };
|
1999-05-06 02:25:20 +08:00
|
|
|
SLS_FETCH();
|
|
|
|
|
1999-05-06 03:53:15 +08:00
|
|
|
if (SG(headers_sent)) {
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sapi_module.send_headers) {
|
|
|
|
retval = sapi_module.send_headers(&SG(sapi_headers) SLS_CC);
|
|
|
|
} else {
|
|
|
|
retval = SAPI_HEADER_DO_SEND;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (retval) {
|
1999-05-06 02:25:20 +08:00
|
|
|
case SAPI_HEADER_SENT_SUCCESSFULLY:
|
1999-05-06 03:53:15 +08:00
|
|
|
SG(headers_sent) = 1;
|
1999-10-05 20:06:35 +08:00
|
|
|
ret = SUCCESS;
|
1999-05-06 02:25:20 +08:00
|
|
|
break;
|
|
|
|
case SAPI_HEADER_DO_SEND:
|
1999-05-12 04:38:16 +08:00
|
|
|
if (SG(sapi_headers).http_status_line) {
|
|
|
|
sapi_header_struct http_status_line;
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
1999-05-06 02:25:20 +08:00
|
|
|
zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) sapi_module.send_header, SG(server_context));
|
1999-12-19 10:04:20 +08:00
|
|
|
if(SG(sapi_headers).send_default_content_type) {
|
|
|
|
sapi_module.send_header(&default_header,SG(server_context));
|
|
|
|
}
|
1999-05-06 05:05:44 +08:00
|
|
|
sapi_module.send_header(NULL, SG(server_context));
|
1999-05-06 03:53:15 +08:00
|
|
|
SG(headers_sent) = 1;
|
1999-10-05 02:07:46 +08:00
|
|
|
ret = SUCCESS;
|
1999-05-06 02:25:20 +08:00
|
|
|
break;
|
|
|
|
case SAPI_HEADER_SEND_FAILED:
|
1999-10-05 02:07:46 +08:00
|
|
|
ret = FAILURE;
|
1999-05-06 02:25:20 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-10-05 02:07:46 +08:00
|
|
|
|
|
|
|
if (SG(sapi_headers).http_status_line) {
|
|
|
|
efree(SG(sapi_headers).http_status_line);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
1999-05-06 02:25:20 +08:00
|
|
|
}
|
1999-05-26 05:14:54 +08:00
|
|
|
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries)
|
1999-09-17 07:18:15 +08:00
|
|
|
{
|
2000-02-18 04:23:59 +08:00
|
|
|
sapi_post_entry *p=post_entries;
|
1999-09-17 07:18:15 +08:00
|
|
|
|
|
|
|
while (p->content_type) {
|
2000-02-18 04:23:59 +08:00
|
|
|
if (sapi_register_post_entry(p)==FAILURE) {
|
1999-09-17 07:18:15 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry)
|
1999-05-26 05:14:54 +08:00
|
|
|
{
|
2000-02-18 04:23:59 +08:00
|
|
|
return zend_hash_add(&known_post_content_types, post_entry->content_type, post_entry->content_type_len+1, (void *) post_entry, sizeof(sapi_post_entry), NULL);
|
1999-05-26 05:14:54 +08:00
|
|
|
}
|
1999-05-26 05:19:46 +08:00
|
|
|
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry)
|
1999-05-26 05:19:46 +08:00
|
|
|
{
|
2000-02-18 04:23:59 +08:00
|
|
|
zend_hash_del(&known_post_content_types, post_entry->content_type, post_entry->content_type_len+1);
|
1999-05-29 06:41:48 +08:00
|
|
|
}
|
1999-09-17 07:18:15 +08:00
|
|
|
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D))
|
1999-09-17 07:18:15 +08:00
|
|
|
{
|
|
|
|
sapi_module.default_post_reader = default_post_reader;
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2000-01-14 01:37:25 +08:00
|
|
|
|
|
|
|
SAPI_API int sapi_flush()
|
|
|
|
{
|
|
|
|
if (sapi_module.flush) {
|
|
|
|
SLS_FETCH();
|
|
|
|
|
2000-02-11 03:29:21 +08:00
|
|
|
sapi_module.flush(SG(server_context));
|
|
|
|
return SUCCESS;
|
|
|
|
} else {
|
|
|
|
return FAILURE;
|
2000-01-14 01:37:25 +08:00
|
|
|
}
|
|
|
|
}
|
2000-02-11 01:26:57 +08:00
|
|
|
|
2000-02-11 02:19:04 +08:00
|
|
|
SAPI_API struct stat *sapi_get_stat()
|
2000-02-11 01:26:57 +08:00
|
|
|
{
|
|
|
|
SLS_FETCH();
|
|
|
|
|
2000-02-11 02:19:04 +08:00
|
|
|
if (sapi_module.get_stat) {
|
|
|
|
return sapi_module.get_stat(SLS_C);
|
2000-02-11 01:26:57 +08:00
|
|
|
} else {
|
2000-02-11 02:19:04 +08:00
|
|
|
if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated, &SG(global_stat))==-1)) {
|
|
|
|
return NULL;
|
2000-02-11 01:26:57 +08:00
|
|
|
}
|
2000-02-11 02:19:04 +08:00
|
|
|
return &SG(global_stat);
|
2000-02-11 01:26:57 +08:00
|
|
|
}
|
|
|
|
}
|
2000-02-11 01:55:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
SAPI_API char *sapi_getenv(char *name, int name_len)
|
|
|
|
{
|
|
|
|
if (sapi_module.getenv) {
|
|
|
|
SLS_FETCH();
|
|
|
|
|
|
|
|
return sapi_module.getenv(name, name_len SLS_CC);
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|