2000-05-29 16:34:19 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-08 08:18:22 +00:00
|
|
|
| PHP Version 5 |
|
2000-05-29 16:34:19 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2007-01-01 09:36:18 +00:00
|
|
|
| Copyright (c) 1997-2007 The PHP Group |
|
2000-05-29 16:34:19 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2000-05-29 16:34:19 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2000-05-29 16:34:19 +00:00
|
|
|
| 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. |
|
|
|
|
+----------------------------------------------------------------------+
|
2002-02-28 08:29:35 +00:00
|
|
|
| Author: |
|
2000-05-29 16:34:19 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2000-07-24 05:41:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1999-09-16 22:15:43 +00:00
|
|
|
#include "php.h"
|
|
|
|
#include "SAPI.h"
|
|
|
|
#include "rfc1867.h"
|
|
|
|
|
1999-12-05 16:43:32 +00:00
|
|
|
#include "php_content_types.h"
|
|
|
|
|
2001-06-06 13:06:12 +00:00
|
|
|
/* {{{ php_post_entries[]
|
|
|
|
*/
|
2000-02-17 20:23:59 +00:00
|
|
|
static sapi_post_entry php_post_entries[] = {
|
2001-09-03 02:31:56 +00:00
|
|
|
{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_std_post_handler },
|
|
|
|
{ MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL, rfc1867_post_handler },
|
|
|
|
{ NULL, 0, NULL, NULL }
|
1999-09-16 23:18:15 +00:00
|
|
|
};
|
2001-06-06 13:06:12 +00:00
|
|
|
/* }}} */
|
1999-09-16 23:18:15 +00:00
|
|
|
|
2001-06-06 13:06:12 +00:00
|
|
|
/* {{{ SAPI_POST_READER_FUNC
|
|
|
|
*/
|
2001-08-15 18:01:48 +00:00
|
|
|
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
|
1999-09-16 23:18:15 +00:00
|
|
|
{
|
2002-11-08 08:41:52 +00:00
|
|
|
char *data = NULL;
|
2002-11-12 18:29:11 +00:00
|
|
|
int length = 0;
|
1999-09-16 23:18:15 +00:00
|
|
|
|
2002-11-29 14:48:17 +00:00
|
|
|
/* $HTTP_RAW_POST_DATA registration */
|
2002-11-12 18:29:11 +00:00
|
|
|
if(!strcmp(SG(request_info).request_method, "POST")) {
|
|
|
|
if(NULL == SG(request_info).post_entry) {
|
|
|
|
/* no post handler registered, so we just swallow the data */
|
|
|
|
sapi_read_standard_form_data(TSRMLS_C);
|
|
|
|
length = SG(request_info).post_data_length;
|
|
|
|
data = estrndup(SG(request_info).post_data, length);
|
|
|
|
} else if(PG(always_populate_raw_post_data) && SG(request_info).post_data) {
|
|
|
|
length = SG(request_info).post_data_length;
|
|
|
|
data = estrndup(SG(request_info).post_data, length);
|
2002-11-08 08:41:52 +00:00
|
|
|
}
|
|
|
|
if(data) {
|
2002-11-12 18:29:11 +00:00
|
|
|
SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
|
2002-11-08 08:41:52 +00:00
|
|
|
}
|
2002-10-21 16:41:06 +00:00
|
|
|
}
|
2002-11-12 18:29:11 +00:00
|
|
|
|
|
|
|
/* for php://input stream:
|
|
|
|
some post handlers modify the content of request_info.post_data
|
|
|
|
so for now we need a copy for the php://input stream
|
|
|
|
in the long run post handlers should be changed to not touch
|
|
|
|
request_info.post_data for memory preservation reasons
|
|
|
|
*/
|
|
|
|
if(SG(request_info).post_data) {
|
|
|
|
SG(request_info).raw_post_data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
|
|
|
|
SG(request_info).raw_post_data_length = SG(request_info).post_data_length;
|
|
|
|
}
|
|
|
|
|
1999-09-16 22:15:43 +00:00
|
|
|
}
|
2001-06-06 13:06:12 +00:00
|
|
|
/* }}} */
|
1999-09-16 22:15:43 +00:00
|
|
|
|
2001-06-06 13:06:12 +00:00
|
|
|
/* {{{ php_startup_sapi_content_types
|
|
|
|
*/
|
2005-02-21 15:14:02 +00:00
|
|
|
int php_startup_sapi_content_types(TSRMLS_D)
|
1999-09-16 22:15:43 +00:00
|
|
|
{
|
1999-09-16 23:18:15 +00:00
|
|
|
sapi_register_default_post_reader(php_default_post_reader);
|
2002-08-02 06:53:48 +00:00
|
|
|
sapi_register_treat_data(php_default_treat_data);
|
2003-02-19 19:41:09 +00:00
|
|
|
sapi_register_input_filter(php_default_input_filter);
|
1999-09-16 22:15:43 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2001-06-06 13:06:12 +00:00
|
|
|
/* }}} */
|
2000-05-29 16:34:19 +00:00
|
|
|
|
2005-03-05 16:41:13 +00:00
|
|
|
/* {{{ php_setup_sapi_content_types
|
|
|
|
*/
|
|
|
|
int php_setup_sapi_content_types(TSRMLS_D)
|
|
|
|
{
|
|
|
|
sapi_register_post_entries(php_post_entries TSRMLS_CC);
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2000-05-29 16:34:19 +00:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
2001-09-09 13:29:31 +00:00
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
2000-05-29 16:34:19 +00:00
|
|
|
*/
|