Permalink
Newer
Older
100644 92 lines (81 sloc) 3.18 KB
1
/*
2
+----------------------------------------------------------------------+
Dec 11, 2001
3
| PHP Version 4 |
4
+----------------------------------------------------------------------+
Dec 11, 2001
5
| Copyright (c) 1997-2002 The PHP Group |
6
+----------------------------------------------------------------------+
May 29, 2000
7
| This source file is subject to version 2.02 of the PHP license, |
8
| that is bundled with this package in the file LICENSE, and is |
9
| available at through the world-wide-web at |
10
| http://www.php.net/license/2_02.txt. |
11
| If you did not receive a copy of the PHP license and are unable to |
12
| obtain it through the world-wide-web, please send a note to |
13
| license@php.net so we can mail you a copy immediately. |
14
+----------------------------------------------------------------------+
Feb 28, 2002
15
| Author: |
16
+----------------------------------------------------------------------+
17
*/
18
19
/* $Id$ */
20
21
#include "php.h"
22
#include "SAPI.h"
23
#include "rfc1867.h"
24
Sascha Schumann
Dec 5, 1999
25
#include "php_content_types.h"
26
27
/* {{{ php_post_entries[]
28
*/
29
static sapi_post_entry php_post_entries[] = {
30
{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_std_post_handler },
31
{ MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL, rfc1867_post_handler },
32
{ NULL, 0, NULL, NULL }
36
/* {{{ SAPI_POST_READER_FUNC
37
*/
38
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
Hartmut Holzgraefe
Nov 8, 2002
40
char *data = NULL;
41
int length = 0;
foobar
MFB
Nov 29, 2002
43
/* $HTTP_RAW_POST_DATA registration */
44
if(!strcmp(SG(request_info).request_method, "POST")) {
45
if(NULL == SG(request_info).post_entry) {
46
/* no post handler registered, so we just swallow the data */
47
sapi_read_standard_form_data(TSRMLS_C);
48
length = SG(request_info).post_data_length;
49
data = estrndup(SG(request_info).post_data, length);
50
} else if(PG(always_populate_raw_post_data) && SG(request_info).post_data) {
51
length = SG(request_info).post_data_length;
52
data = estrndup(SG(request_info).post_data, length);
Hartmut Holzgraefe
Nov 8, 2002
53
}
54
if(data) {
55
SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
Hartmut Holzgraefe
Nov 8, 2002
56
}
58
59
/* for php://input stream:
60
some post handlers modify the content of request_info.post_data
61
so for now we need a copy for the php://input stream
62
in the long run post handlers should be changed to not touch
63
request_info.post_data for memory preservation reasons
64
*/
65
if(SG(request_info).post_data) {
66
SG(request_info).raw_post_data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
67
SG(request_info).raw_post_data_length = SG(request_info).post_data_length;
68
}
69
70
}
72
73
/* {{{ php_startup_sapi_content_types
74
*/
75
int php_startup_sapi_content_types(void)
76
{
77
sapi_register_post_entries(php_post_entries);
78
sapi_register_default_post_reader(php_default_post_reader);
79
sapi_register_treat_data(php_default_treat_data);
80
return SUCCESS;
81
}
83
84
/*
85
* Local variables:
86
* tab-width: 4
87
* c-basic-offset: 4
88
* End:
89
* vim600: sw=4 ts=4 fdm=marker
90
* vim<600: sw=4 ts=4