xref: /php-src/main/php_content_types.c (revision 01b3fc03)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Author:                                                              |
14    +----------------------------------------------------------------------+
15 */
16 
17 #include "php.h"
18 #include "SAPI.h"
19 #include "rfc1867.h"
20 
21 #include "php_content_types.h"
22 
23 /* {{{ php_post_entries[] */
24 static const sapi_post_entry php_post_entries[] = {
25 	{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data,	php_std_post_handler },
26 	{ MULTIPART_CONTENT_TYPE,    sizeof(MULTIPART_CONTENT_TYPE)-1,    NULL,                         rfc1867_post_handler },
27 	{ NULL, 0, NULL, NULL }
28 };
29 /* }}} */
30 
31 /* {{{ SAPI_POST_READER_FUNC */
SAPI_POST_READER_FUNC(php_default_post_reader)32 SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
33 {
34 	if (!strcmp(SG(request_info).request_method, "POST")) {
35 		if (NULL == SG(request_info).post_entry) {
36 			/* no post handler registered, so we just swallow the data */
37 			sapi_read_standard_form_data();
38 		}
39 	}
40 }
41 /* }}} */
42 
43 /* {{{ php_startup_sapi_content_types */
php_startup_sapi_content_types(void)44 int php_startup_sapi_content_types(void)
45 {
46 	sapi_register_default_post_reader(php_default_post_reader);
47 	sapi_register_treat_data(php_default_treat_data);
48 	sapi_register_input_filter(php_default_input_filter, NULL);
49 	return SUCCESS;
50 }
51 /* }}} */
52 
53 /* {{{ php_setup_sapi_content_types */
php_setup_sapi_content_types(void)54 int php_setup_sapi_content_types(void)
55 {
56 	sapi_register_post_entries(php_post_entries);
57 
58 	return SUCCESS;
59 }
60 /* }}} */
61