xref: /PHP-7.4/main/php_content_types.c (revision 92ac598a)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.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    +----------------------------------------------------------------------+
15    | Author:                                                              |
16    +----------------------------------------------------------------------+
17 */
18 
19 #include "php.h"
20 #include "SAPI.h"
21 #include "rfc1867.h"
22 
23 #include "php_content_types.h"
24 
25 /* {{{ php_post_entries[]
26  */
27 static const sapi_post_entry php_post_entries[] = {
28 	{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data,	php_std_post_handler },
29 	{ MULTIPART_CONTENT_TYPE,    sizeof(MULTIPART_CONTENT_TYPE)-1,    NULL,                         rfc1867_post_handler },
30 	{ NULL, 0, NULL, NULL }
31 };
32 /* }}} */
33 
34 /* {{{ SAPI_POST_READER_FUNC
35  */
SAPI_POST_READER_FUNC(php_default_post_reader)36 SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
37 {
38 	if (!strcmp(SG(request_info).request_method, "POST")) {
39 		if (NULL == SG(request_info).post_entry) {
40 			/* no post handler registered, so we just swallow the data */
41 			sapi_read_standard_form_data();
42 		}
43 	}
44 }
45 /* }}} */
46 
47 /* {{{ php_startup_sapi_content_types
48  */
php_startup_sapi_content_types(void)49 int php_startup_sapi_content_types(void)
50 {
51 	sapi_register_default_post_reader(php_default_post_reader);
52 	sapi_register_treat_data(php_default_treat_data);
53 	sapi_register_input_filter(php_default_input_filter, NULL);
54 	return SUCCESS;
55 }
56 /* }}} */
57 
58 /* {{{ php_setup_sapi_content_types
59  */
php_setup_sapi_content_types(void)60 int php_setup_sapi_content_types(void)
61 {
62 	sapi_register_post_entries(php_post_entries);
63 
64 	return SUCCESS;
65 }
66 /* }}} */
67