--- /dev/null
+.deps
+*.lo
+*.la
+.libs
+acinclude.m4
+aclocal.m4
+autom4te.cache
+build
+config.guess
+config.h
+config.h.in
+config.log
+config.nice
+config.status
+config.sub
+configure
+configure.in
+include
+install-sh
+libtool
+ltmain.sh
+Makefile
+Makefile.fragments
+Makefile.global
+Makefile.objects
+missing
+mkinstalldirs
+modules
+run-tests.php
+tests/*/*.diff
+tests/*/*.out
+tests/*/*.php
+tests/*/*.exp
+tests/*/*.log
+tests/*/*.sh
+php_apfd.o
--- /dev/null
+apfd
+Michael Wallner
--- /dev/null
+Copyright (c) 2015, Michael Wallner <mike@iworks.at>.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+PHP_ARG_ENABLE(apfd, whether to enable apfd support,
+[ --enable-apfd Enable always-populate-form-data support])
+
+if test "$PHP_APFD" != "no"; then
+ PHP_NEW_EXTENSION(apfd, php_apfd.c, $ext_shared)
+fi
--- /dev/null
+ARG_ENABLE("apfd", "enable apfd support", "no");
+
+if (PHP_APFD != "no") {
+ EXTENSION("apfd", "php_apfd.c");
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0"
+ xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://pear.php.net/dtd/tasks-1.0
+ http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0
+ http://pear.php.net/dtd/package-2.0.xsd">
+ <name>apfd</name>
+ <channel>pecl.php.net</channel>
+ <summary>Always Populate Form Data</summary>
+ <description><![CDATA[
+This tiny extension lets PHP's post handler parse `multipart/form-data` and
+`application/x-www-form-urlencoded` (or any other customly registered form data
+handler, like "json_post") without regard to the request's request method.
+
+This extension does not provide any INI entries, constants, functions or classes.
+
+]]></description>
+ <lead>
+ <name>Michael Wallner</name>
+ <user>mike</user>
+ <email>mike@php.net</email>
+ <active>yes</active>
+ </lead>
+ <date>2015-03-01</date>
+ <version>
+ <release>1.0.0</release>
+ <api>1.0.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license>BSD, revised</license>
+ <notes><![CDATA[
+* Split off pecl_http
+]]></notes>
+ <contents>
+ <dir name="/">
+ <file role="doc" name="LICENSE"/>
+ <file role="doc" name="CREDITS"/>
+ <file role="src" name="config.m4"/>
+ <file role="src" name="config.w32"/>
+
+ <file role="src" name="php_apfd.h"/>
+ <file role="src" name="php_apfd.c"/>
+
+ <dir name="tests">
+ <file role="test" name="001.phpt"/>
+ <file role="test" name="002.phpt"/>
+ </dir>
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.3.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.1</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <providesextension>apfd</providesextension>
+ <extsrcrelease/>
+ <changelog />
+</package>
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | PECL :: apfd |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted provided that the conditions mentioned |
+ | in the accompanying LICENSE file are met. |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2015, Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "SAPI.h"
+#include "php_apfd.h"
+
+PHP_RINIT_FUNCTION(apfd)
+{
+ /* populate form data on non-POST requests */
+ if (SG(request_info).request_method && strcasecmp(SG(request_info).request_method, "POST") && SG(request_info).content_type && *SG(request_info).content_type) {
+ char *ct_str = zend_str_tolower_dup(SG(request_info).content_type, strlen(SG(request_info).content_type));
+ size_t ct_end = strcspn(ct_str, ";, ");
+ sapi_post_entry *post_entry = NULL;
+ char delim;
+
+ SG(request_info).content_type_dup = ct_str;
+
+ delim = ct_str[ct_end];
+ ct_str[ct_end] = '\0';
+
+ if (SUCCESS == zend_hash_find(&SG(known_post_content_types), ct_str, ct_end+1, (void *) &post_entry)) {
+ zval *files = PG(http_globals)[TRACK_VARS_FILES];
+
+ ct_str[ct_end] = delim;
+
+ if (post_entry) {
+ SG(request_info).post_entry = post_entry;
+
+ if (post_entry->post_reader) {
+ post_entry->post_reader(TSRMLS_C);
+ }
+ }
+
+ if (sapi_module.default_post_reader) {
+ sapi_module.default_post_reader(TSRMLS_C);
+ }
+
+ sapi_handle_post(PG(http_globals)[TRACK_VARS_POST] TSRMLS_CC);
+
+ /*
+ * the rfc1867 handler is an awkward buddy
+ */
+ if (files != PG(http_globals)[TRACK_VARS_FILES] && PG(http_globals)[TRACK_VARS_FILES]) {
+ Z_ADDREF_P(PG(http_globals)[TRACK_VARS_FILES]);
+ zend_hash_update(&EG(symbol_table), "_FILES", sizeof("_FILES"), &PG(http_globals)[TRACK_VARS_FILES], sizeof(zval *), NULL);
+ if (files) {
+ zval_ptr_dtor(&files);
+ }
+ }
+ }
+
+ if (SG(request_info).content_type_dup) {
+ efree(SG(request_info).content_type_dup);
+ SG(request_info).content_type_dup = NULL;
+ }
+ }
+
+ return SUCCESS;
+}
+
+PHP_MINFO_FUNCTION(apfd)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "apfd support", "enabled");
+ php_info_print_table_end();
+}
+
+const zend_function_entry apfd_functions[] = {
+ {0}
+};
+
+zend_module_entry apfd_module_entry = {
+ STANDARD_MODULE_HEADER,
+ "apfd",
+ apfd_functions,
+ NULL,
+ NULL,
+ PHP_RINIT(apfd),
+ NULL,
+ PHP_MINFO(apfd),
+ PHP_APFD_VERSION,
+ STANDARD_MODULE_PROPERTIES
+};
+
+#ifdef COMPILE_DL_APFD
+ZEND_GET_MODULE(apfd)
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | PECL :: apfd |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted provided that the conditions mentioned |
+ | in the accompanying LICENSE file are met. |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2015, Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#ifndef PHP_APFD_H
+#define PHP_APFD_H
+
+extern zend_module_entry apfd_module_entry;
+#define phpext_apfd_ptr &apfd_module_entry
+
+#define PHP_APFD_VERSION "1.0.0"
+
+#ifdef PHP_WIN32
+# define PHP_APFD_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_APFD_API extern __attribute__ ((visibility("default")))
+#else
+# define PHP_APFD_API extern
+#endif
+
+#ifdef ZTS
+# include "TSRM.h"
+#endif
+
+#endif /* PHP_APFD_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
--- /dev/null
+--TEST--
+apfd
+--SKIPIF--
+<?php
+extension_loaded("apfd") or die("skip need apfd support\n");
+?>
+--PUT--
+Content-Type: application/x-www-form-urlencoded
+foo=bar&bar=foo
+--FILE--
+<?php
+
+var_dump($_POST);
+
+?>
+--EXPECT--
+array(2) {
+ ["foo"]=>
+ string(3) "bar"
+ ["bar"]=>
+ string(3) "foo"
+}
--- /dev/null
+--TEST--
+apfd
+--SKIPIF--
+<?php
+extension_loaded("apfd") or die("skip need apfd support\n");
+?>
+--PUT--
+Content-Type: multipart/form-data; boundary=----------------------------6e182425881c
+------------------------------6e182425881c
+Content-Disposition: form-data; name="LICENSE"; filename="LICENSE"
+Content-Type: application/octet-stream
+
+Copyright (c) 2011-2012, Michael Wallner <mike@iworks.at>.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+------------------------------6e182425881c
+Content-Disposition: form-data; name="composer"; filename="composer.json"
+Content-Type: application/octet-stream
+
+{
+ "name": "m6w6/autocracy",
+ "type": "library",
+ "description": "http\\Controller preserves your autocracy",
+ "keywords": ["http", "controller", "pecl", "pecl_http"],
+ "homepage": "http://github.com/m6w6/autocracy",
+ "license": "BSD-2",
+ "authors": [
+ {
+ "name": "Michael Wallner",
+ "email": "mike@php.net"
+ }
+ ],
+ "require": {
+ "php": ">=5.4.0",
+ "pecl/pecl_http": "2.*"
+ },
+ "autoload": {
+ "psr-0": {
+ "http\\Controller": "lib"
+ }
+ }
+}
+
+------------------------------6e182425881c--
+--FILE--
+<?php
+
+var_dump($_POST, $_FILES);
+
+?>
+--EXPECTF--
+array(0) {
+}
+array(2) {
+ ["LICENSE"]=>
+ array(5) {
+ ["name"]=>
+ string(7) "LICENSE"
+ ["type"]=>
+ string(24) "application/octet-stream"
+ ["tmp_name"]=>
+ string(66) "%sphp%s"
+ ["error"]=>
+ int(0)
+ ["size"]=>
+ int(1353)
+ }
+ ["composer"]=>
+ array(5) {
+ ["name"]=>
+ string(13) "composer.json"
+ ["type"]=>
+ string(24) "application/octet-stream"
+ ["tmp_name"]=>
+ string(66) "%sphp%s"
+ ["error"]=>
+ int(0)
+ ["size"]=>
+ int(550)
+ }
+}
\ No newline at end of file