This source file includes following definitions.
- populate_raw_post_data
- SAPI_POST_READER_FUNC
- php_startup_sapi_content_types
- php_setup_sapi_content_types
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "php.h"
22 #include "SAPI.h"
23 #include "rfc1867.h"
24
25 #include "php_content_types.h"
26
27
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 }
33 };
34
35
36 static zend_bool populate_raw_post_data(TSRMLS_D)
37 {
38 if (!SG(request_info).request_body) {
39 return (zend_bool) 0;
40 }
41
42 if (!PG(always_populate_raw_post_data)) {
43 return (zend_bool) !SG(request_info).post_entry;
44 }
45
46 return (zend_bool) (PG(always_populate_raw_post_data) > 0);
47 }
48
49
50
51 SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
52 {
53 if (!strcmp(SG(request_info).request_method, "POST")) {
54 if (NULL == SG(request_info).post_entry) {
55
56 sapi_read_standard_form_data(TSRMLS_C);
57 }
58
59 if (populate_raw_post_data(TSRMLS_C)) {
60 size_t length;
61 char *data = NULL;
62
63 php_stream_rewind(SG(request_info).request_body);
64 length = php_stream_copy_to_mem(SG(request_info).request_body, &data, PHP_STREAM_COPY_ALL, 0);
65 php_stream_rewind(SG(request_info).request_body);
66
67 if (length > INT_MAX) {
68 sapi_module.sapi_error(E_WARNING,
69 "HTTP_RAW_POST_DATA truncated from %lu to %d bytes",
70 (unsigned long) length, INT_MAX);
71 length = INT_MAX;
72 }
73 SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
74
75 sapi_module.sapi_error(E_DEPRECATED,
76 "Automatically populating $HTTP_RAW_POST_DATA is deprecated and "
77 "will be removed in a future version. To avoid this warning set "
78 "'always_populate_raw_post_data' to '-1' in php.ini and use the "
79 "php://input stream instead.");
80 }
81 }
82 }
83
84
85
86
87 int php_startup_sapi_content_types(TSRMLS_D)
88 {
89 sapi_register_default_post_reader(php_default_post_reader TSRMLS_CC);
90 sapi_register_treat_data(php_default_treat_data TSRMLS_CC);
91 sapi_register_input_filter(php_default_input_filter, NULL TSRMLS_CC);
92 return SUCCESS;
93 }
94
95
96
97
98 int php_setup_sapi_content_types(TSRMLS_D)
99 {
100 sapi_register_post_entries(php_post_entries TSRMLS_CC);
101
102 return SUCCESS;
103 }
104
105
106
107
108
109
110
111
112
113