attempt to implement some personal standards
authorMichael Wallner <mike@php.net>
Mon, 28 Sep 2015 14:08:14 +0000 (16:08 +0200)
committerMichael Wallner <mike@php.net>
Mon, 28 Sep 2015 14:08:14 +0000 (16:08 +0200)
147 files changed:
.editorconfig [new file with mode: 0644]
.gitignore
AUTHORS [new file with mode: 0644]
BUGS [new file with mode: 0644]
CONTRIBUTING.md [new file with mode: 0644]
Exceptions.txt [deleted file]
KnownIssues.txt [deleted file]
LICENSE
Makefile.frag [new file with mode: 0644]
README.md
THANKS [new file with mode: 0644]
ThanksTo.txt [deleted file]
bench_select_vs_event.php [deleted file]
check_package-xml.php [deleted file]
config.w32
config9.m4
gen_curlinfo.php [deleted file]
gen_travis_yml.php [deleted file]
gen_utf8.php [deleted file]
package.xml
php_http.c [deleted file]
php_http_api.h [deleted file]
php_http_buffer.c [deleted file]
php_http_buffer.h [deleted file]
php_http_client.c [deleted file]
php_http_client.h [deleted file]
php_http_client_curl.c [deleted file]
php_http_client_curl.h [deleted file]
php_http_client_request.c [deleted file]
php_http_client_request.h [deleted file]
php_http_client_response.c [deleted file]
php_http_client_response.h [deleted file]
php_http_cookie.c [deleted file]
php_http_cookie.h [deleted file]
php_http_curl.c [deleted file]
php_http_curl.h [deleted file]
php_http_encoding.c [deleted file]
php_http_encoding.h [deleted file]
php_http_env.c [deleted file]
php_http_env.h [deleted file]
php_http_env_request.c [deleted file]
php_http_env_request.h [deleted file]
php_http_env_response.c [deleted file]
php_http_env_response.h [deleted file]
php_http_etag.c [deleted file]
php_http_etag.h [deleted file]
php_http_exception.c [deleted file]
php_http_exception.h [deleted file]
php_http_filter.c [deleted file]
php_http_filter.h [deleted file]
php_http_header.c [deleted file]
php_http_header.h [deleted file]
php_http_header_parser.c [deleted file]
php_http_header_parser.h [deleted file]
php_http_info.c [deleted file]
php_http_info.h [deleted file]
php_http_message.c [deleted file]
php_http_message.h [deleted file]
php_http_message_body.c [deleted file]
php_http_message_body.h [deleted file]
php_http_message_parser.c [deleted file]
php_http_message_parser.h [deleted file]
php_http_misc.c [deleted file]
php_http_misc.h [deleted file]
php_http_negotiate.c [deleted file]
php_http_negotiate.h [deleted file]
php_http_object.c [deleted file]
php_http_object.h [deleted file]
php_http_options.c [deleted file]
php_http_options.h [deleted file]
php_http_params.c [deleted file]
php_http_params.h [deleted file]
php_http_querystring.c [deleted file]
php_http_querystring.h [deleted file]
php_http_response_codes.h [deleted file]
php_http_url.c [deleted file]
php_http_url.h [deleted file]
php_http_utf8.h [deleted file]
php_http_version.c [deleted file]
php_http_version.h [deleted file]
reflection2php.php [deleted file]
scripts/bench_select_vs_event.php [new file with mode: 0644]
scripts/check_package-xml.php [new file with mode: 0755]
scripts/gen_curlinfo.php [new file with mode: 0755]
scripts/gen_stubs.php [new file with mode: 0755]
scripts/gen_travis_yml.php [new file with mode: 0755]
scripts/gen_utf8.php [new file with mode: 0755]
src/php_http.c [new file with mode: 0644]
src/php_http_api.h [new file with mode: 0644]
src/php_http_buffer.c [new file with mode: 0644]
src/php_http_buffer.h [new file with mode: 0644]
src/php_http_client.c [new file with mode: 0644]
src/php_http_client.h [new file with mode: 0644]
src/php_http_client_curl.c [new file with mode: 0644]
src/php_http_client_curl.h [new file with mode: 0644]
src/php_http_client_request.c [new file with mode: 0644]
src/php_http_client_request.h [new file with mode: 0644]
src/php_http_client_response.c [new file with mode: 0644]
src/php_http_client_response.h [new file with mode: 0644]
src/php_http_cookie.c [new file with mode: 0644]
src/php_http_cookie.h [new file with mode: 0644]
src/php_http_curl.c [new file with mode: 0644]
src/php_http_curl.h [new file with mode: 0644]
src/php_http_encoding.c [new file with mode: 0644]
src/php_http_encoding.h [new file with mode: 0644]
src/php_http_env.c [new file with mode: 0644]
src/php_http_env.h [new file with mode: 0644]
src/php_http_env_request.c [new file with mode: 0644]
src/php_http_env_request.h [new file with mode: 0644]
src/php_http_env_response.c [new file with mode: 0644]
src/php_http_env_response.h [new file with mode: 0644]
src/php_http_etag.c [new file with mode: 0644]
src/php_http_etag.h [new file with mode: 0644]
src/php_http_exception.c [new file with mode: 0644]
src/php_http_exception.h [new file with mode: 0644]
src/php_http_filter.c [new file with mode: 0644]
src/php_http_filter.h [new file with mode: 0644]
src/php_http_header.c [new file with mode: 0644]
src/php_http_header.h [new file with mode: 0644]
src/php_http_header_parser.c [new file with mode: 0644]
src/php_http_header_parser.h [new file with mode: 0644]
src/php_http_info.c [new file with mode: 0644]
src/php_http_info.h [new file with mode: 0644]
src/php_http_message.c [new file with mode: 0644]
src/php_http_message.h [new file with mode: 0644]
src/php_http_message_body.c [new file with mode: 0644]
src/php_http_message_body.h [new file with mode: 0644]
src/php_http_message_parser.c [new file with mode: 0644]
src/php_http_message_parser.h [new file with mode: 0644]
src/php_http_misc.c [new file with mode: 0644]
src/php_http_misc.h [new file with mode: 0644]
src/php_http_negotiate.c [new file with mode: 0644]
src/php_http_negotiate.h [new file with mode: 0644]
src/php_http_object.c [new file with mode: 0644]
src/php_http_object.h [new file with mode: 0644]
src/php_http_options.c [new file with mode: 0644]
src/php_http_options.h [new file with mode: 0644]
src/php_http_params.c [new file with mode: 0644]
src/php_http_params.h [new file with mode: 0644]
src/php_http_querystring.c [new file with mode: 0644]
src/php_http_querystring.h [new file with mode: 0644]
src/php_http_response_codes.h [new file with mode: 0644]
src/php_http_url.c [new file with mode: 0644]
src/php_http_url.h [new file with mode: 0644]
src/php_http_utf8.h [new file with mode: 0644]
src/php_http_version.c [new file with mode: 0644]
src/php_http_version.h [new file with mode: 0644]

diff --git a/.editorconfig b/.editorconfig
new file mode 100644 (file)
index 0000000..e0c3b0e
--- /dev/null
@@ -0,0 +1,20 @@
+; see http://editorconfig.org
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+indent_style = tab
+charset = utf-8
+trim_trailing_whitespace = true
+
+[package.xml]
+indent_style = space
+indent_size = 1
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.json]
+indent_style = space
+indent_size = 4
index c78e2b8..fc8d761 100644 (file)
@@ -40,3 +40,4 @@ tests/*.sh
 lcov_data
 *~
 *.phar
+vendor/
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..67bbd91
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Michael Wallner <mike@php.net>
diff --git a/BUGS b/BUGS
new file mode 100644 (file)
index 0000000..4c2ad80
--- /dev/null
+++ b/BUGS
@@ -0,0 +1,25 @@
+Known Issues
+============
+
+Windows:
+       If you keep getting "SSL connect error" when trying to issue 
+               requests, try another (newer) libeay32.dll/ssleay32.dll pair.
+
+Internals:
+       Inflating raw deflated data causes a re-initialization of the inflate
+               stream where the corresponding window bits are modified to tell libz
+               to not check for zlib header bytes.  This is not preventable AFAICS.
+       LFS dependant parts of libcurl are left out because of off_t,
+               respectively off64_t confusion.
+       Persistent handles and "cookiestore" request option do interfere,
+               as libcurl saves the cookies to the file on curl_easy_destroy(),
+               cookies are not saved until the CURL handle will be recycled.
+                       Thus one would either need to
+                               * run PHP with raphf.persistent_handles.limit = 0
+                               * call raphf\persistent_handles_clean() every request
+                               * call $client->flushCookies(), which is available
+                                 since libcurl v7.17.1 and does not work with the
+                                 procedural API
+       HTTP and Proxy authentication information (username/password) can not be
+               unset with NULL prior libcurl v7.19.6 and separate options for setting
+               username and password--which work--are only available since v7.19.6.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..968bd44
--- /dev/null
@@ -0,0 +1,39 @@
+# Contributor Code of Conduct
+
+As contributors and maintainers of this project, and in the interest of
+fostering an open and welcoming community, we pledge to respect all people who
+contribute through reporting issues, posting feature requests, updating
+documentation, submitting pull requests or patches, and other activities.
+
+We are committed to making participation in this project a harassment-free
+experience for everyone, regardless of level of experience, gender, gender
+identity and expression, sexual orientation, disability, personal appearance,
+body size, race, ethnicity, age, religion, or nationality.
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery
+* Personal attacks
+* Trolling or insulting/derogatory comments
+* Public or private harassment
+* Publishing other's private information, such as physical or electronic
+  addresses, without explicit permission
+* Other unethical or unprofessional conduct.
+
+Project maintainers have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct. By adopting this Code of Conduct, project
+maintainers commit themselves to fairly and consistently applying these
+principles to every aspect of managing this project. Project maintainers who do
+not follow or enforce the Code of Conduct may be permanently removed from the
+project team.
+
+This code of conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community.
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by opening an issue or contacting one or more of the project maintainers.
+
+This Code of Conduct is adapted from the
+[Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
+available at http://contributor-covenant.org/version/1/2/0/.
diff --git a/Exceptions.txt b/Exceptions.txt
deleted file mode 100644 (file)
index f666ee9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# Throw Exceptions:
-
-* on setters, that return self
-* on getters, that return objects
diff --git a/KnownIssues.txt b/KnownIssues.txt
deleted file mode 100644 (file)
index 4c2ad80..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-Known Issues
-============
-
-Windows:
-       If you keep getting "SSL connect error" when trying to issue 
-               requests, try another (newer) libeay32.dll/ssleay32.dll pair.
-
-Internals:
-       Inflating raw deflated data causes a re-initialization of the inflate
-               stream where the corresponding window bits are modified to tell libz
-               to not check for zlib header bytes.  This is not preventable AFAICS.
-       LFS dependant parts of libcurl are left out because of off_t,
-               respectively off64_t confusion.
-       Persistent handles and "cookiestore" request option do interfere,
-               as libcurl saves the cookies to the file on curl_easy_destroy(),
-               cookies are not saved until the CURL handle will be recycled.
-                       Thus one would either need to
-                               * run PHP with raphf.persistent_handles.limit = 0
-                               * call raphf\persistent_handles_clean() every request
-                               * call $client->flushCookies(), which is available
-                                 since libcurl v7.17.1 and does not work with the
-                                 procedural API
-       HTTP and Proxy authentication information (username/password) can not be
-               unset with NULL prior libcurl v7.19.6 and separate options for setting
-               username and password--which work--are only available since v7.19.6.
diff --git a/LICENSE b/LICENSE
index 786ba27..c7d1587 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2014, Michael Wallner <mike@iworks.at>.
+Copyright (c) 2004-2015, Michael Wallner <mike@php.net>.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without 
diff --git a/Makefile.frag b/Makefile.frag
new file mode 100644 (file)
index 0000000..3ef9ecb
--- /dev/null
@@ -0,0 +1,16 @@
+# provide headers in builddir, so they do not end up in /usr/include/ext/http/src
+
+PHP_HTTP_HEADERS := $(addprefix $(PHP_HTTP_BUILDDIR)/,$(PHP_HTTP_HEADERS))
+
+$(PHP_HTTP_BUILDDIR)/%.h: $(PHP_HTTP_SRCDIR)/src/%.h
+       @cat >$@ <$<
+
+all: http-build-headers
+clean: http-clean-headers
+
+.PHONY: http-build-headers
+http-build-headers: $(PHP_HTTP_HEADERS)
+
+.PHONY: http-clean-headers
+http-clean-headers:
+       -rm $(PHP_HTTP_HEADERS)
index c0ee4d1..19738da 100644 (file)
--- a/README.md
+++ b/README.md
-# pecl/http v2
+# ext-http
 
-[![Build Status](https://travis-ci.org/m6w6/ext-http.svg?branch=R_2_5)](https://travis-ci.org/m6w6/ext-http)
+[![Build Status](https://travis-ci.org/m6w6/ext-http.svg?branch=master)](https://travis-ci.org/m6w6/ext-http)
 
-## About:
+Extended HTTP support. Again.
 
-Extended HTTP support. Again. 
+## Documentation
 
-* Introduces the http namespace.
-* PHP stream based message bodies.
-* Encapsulated env request/response.
-* Modular client support.
+See the [online markdown reference](https://mdref.m6w6.name/http).
 
-## Installation:
+Known issues are listed in [BUGS](./BUGS) and future ideas can be found in [TODO](./TODO).
 
-This extension is hosted at [PECL](http://pecl.php.net) and can be installed with [PEAR](http://pear.php.net)'s pecl command:
+## Installing
 
-    # pecl install pecl_http
+### PECL
 
-## Dependencies:
+       pecl install pecl_http
 
-pecl/http depends on a number of system libraries and PHP extensions for special features.
+### PHARext
 
-#### Required system libraries:
+Watch out for [PECL replicates](https://replicator.pharext.org?pecl_http)
+and pharext packages attached to [releases](./releases).
 
-The following system libraries are required to build this extension:
+### Checkout
 
-##### zlib
-Provides gzip/zlib/deflate encoding.  
-Minimum version: 1.2.0.4  
-Install on Debian: `apt-get install zlib1g-dev`
+       git clone github.com:m6w6/ext-http
+       cd ext-http
+       /path/to/phpize
+       ./configure --with-php-config=/path/to/php-config
+       make
+       sudo make install
 
+## ChangeLog
 
-#### Optional system libraries:
+A comprehensive list of changes can be obtained from the
+[PECL website](https://pecl.php.net/package-changelog.php?package=pecl_http).
 
-The following system libraries are optional and provide additional features:
+## License
 
-##### libidn
-Provides IDNA support in URLs.  
-Minimum version: none  
-Install on Debian: `apt-get install libidn11-dev`
+ext-http is licensed under the 2-Clause-BSD license, which can be found in
+the accompanying [LICENSE](./LICENSE) file.
 
-##### libidn2
-Provides IDNA support in URLs (fallback if libidn is not available).  
-Minimum version: none  
-Install on Debian: `apt-get install libidn2-0-dev`
+## Contributing
 
-##### libicu
-Provides IDNA support in URLs (fallback if libidn is not available).  
-Minimum version: none  
-Install on Debian: `apt-get install libicu-dev`
+All forms of contribution are welcome! Please see the bundled
+[CONTRIBUTING](./CONTRIBUTING.md) note for the general principles followed.
 
-##### libcurl
-Provides HTTP request functionality.  
-Minimum version: 7.18.2  
-Install on Debian: `apt-get install libcurl4-openssl-dev`  
-Note: There are usually different styles of SSL support for libcurl available, so you can replace 'openssl' in the above command f.e. with 'nss' or 'gnutls'.
-
-##### libevent
-Eventloop support for the HTTP client.  
-Minimum version: none  
-Install on Debian: `apt-get install libevent-dev`
-
-### PHP extensions:
-
-This extension unconditionally depends on the pre-loaded presence of the following PHP extensions:
-
-* [raphf](https://github.com/m6w6/ext-raphf)
-* [propro](https://github.com/m6w6/ext-propro)
-* spl
-
-
-If configured ```--with-http-shared-deps``` (default) it depends on the pre-loaded presence of the following extensions, as long as they were available at build time:
-
-* hash
-* iconv
-* json (only until < 2.4.0)
-
-Please ensure that all extension on which pecl/http depends, are loaded before it, e.g in your `php.ini`:
-
-       ; obligatory deps
-       extension = raphf.so
-       extension = propro.so
-       
-       ; if shared deps were enabled
-       extension = hash.so
-       extension = iconv.so
-       extension = json.so
-       
-       ; finally load pecl/http
-       extension = http.so
-
-## Conflicts:
-
-pecl/http-v2 conflicts with the following extensions:
-
-* http-v1
-* event (only until <= 2.0.3)
-
-## INI Directives:
-
-* http.etag.mode = "crc32b"  
-  Default hash method for dynamic response payloads to generate an ETag.
-
-## Stream Filters:
-
-The http extension registers the ```http.*``` namespace for its stream filters. Provided stream filters are:
-
-* http.chunked_decode  
-  Decode a stream encoded with chunked transfer encoding.
-* http.chunked_encode  
-  Encode a stream with chunked transfer encoding.
-* http.inflate  
-  Decode a stream encoded with deflate/zlib/gzip encoding.
-* http.deflate  
-  Encode a stream with deflate/zlib/gzip encoding.
-
-
-## Documentation:
-
-Documentation is available at https://mdref.m6w6.name/http
+The list of past and current contributors is maintained in [THANKS](./THANKS).
diff --git a/THANKS b/THANKS
new file mode 100644 (file)
index 0000000..d5ddcb5
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,15 @@
+Thanks go to the following people, who have contributed to this project:
+
+       Ilia Alshanetsky (ilia at php dot net)
+       Anatol Belski (ab at php dot net)
+       Petr Czaderna (petr at hroch dot info)
+       Remi Collet (remi at php dot net)
+       Benjamin Eberlei (kontakt at beberlei dot de)
+       David James (james82 at gmail dot com)
+       Thomas Landro Johnsen (thomas dot l dot johnsen at gmail dot com)
+       Clay Loveless (clay at killersoft dot com)
+       Felipe Pena (felipe at php dot net)
+       David Sklar (sklar at sklar dot com)
+       Travis Swicegood (travis at mashery dot com)
+       Alexey Zakhlestin (indeyets at gmail dot com)
+       Alexander Zhuravlev (zaa at zaa dot pp dot ru)
diff --git a/ThanksTo.txt b/ThanksTo.txt
deleted file mode 100644 (file)
index 67c5b32..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-Thanks To
-=========
-
-People who repeatedly reported issues with this extension in a manner
-so they could be fixed in a reasonable way, or suggested useful features
-to implement, in alphabetical order:
-
-       Ilia Alshanetsky (ilia at php dot net)
-       Anatol Belski (ab at php dot net)
-       Petr Czaderna (petr at hroch dot info)
-       Remi Collet (remi at php dot net)
-       Benjamin Eberlei (kontakt at beberlei dot de)
-       David James (james82 at gmail dot com)
-       Thomas Landro Johnsen (thomas dot l dot johnsen at gmail dot com)
-       Clay Loveless (clay at killersoft dot com)
-       Felipe Pena (felipe at php dot net)
-       David Sklar (sklar at sklar dot com)
-       Travis Swicegood (travis at mashery dot com)
-       Alexey Zakhlestin (indeyets at gmail dot com)
-       Alexander Zhuravlev (zaa at zaa dot pp dot ru)
-
-Thanks a lot!
diff --git a/bench_select_vs_event.php b/bench_select_vs_event.php
deleted file mode 100644 (file)
index 3bc9aed..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-function usage($e = null) {
-    global $argv;
-    if ($e) {
-        fprintf(STDERR, "ERROR: %s\n\n", $e);
-    }
-       fprintf(STDERR, "Usage: %s -u <URL> -n <requests> -c <concurrency> [-p (enable pipelining)] [-e (use libevent)]\n", $argv[0]);
-       fprintf(STDERR, "\nDefaults: -u http://localhost/ -n 1000 -c 10\n\n");
-       exit(-1);
-}
-
-function push($client, $url, &$n) {
-       if ($n-- > 0) {
-               $req = new http\Client\Request("GET", $url);
-               $client->enqueue($req, function($response) use ($client, $req, $url, &$n) {
-                       global $count; ++$count;
-                       push($client, $url, $n);
-                       return true; // dequeue
-               });
-       }
-}
-
-isset($argv) or $argv = $_SERVER['argv'];
-defined('STDERR') or define('STDERR', fopen('php://stderr', 'w'));
-
-$opts = getopt("u:c:n:e");
-isset($opts["u"]) or $opts["u"] = "http://localhost/";
-isset($opts["c"]) or $opts["c"] = 10;
-isset($opts["n"]) or $opts["n"] = 1000;
-
-$argc > 1 or usage();
-
-$time = microtime(true);
-$count = 0;
-$client = new http\Client;
-
-$client->enablePipelining($opts["p"]===false);
-$client->enableEvents($opts["e"]===false);
-
-for ($i = 0, $x = $opts["n"]; $i < $opts["c"]; ++$i) {
-       push($client, $opts["u"], $x);
-}
-
-try {
-       $client->send();
-} catch (Exception $e) {
-       echo $e;
-}
-
-printf("\n> %10.6fs (%3.2fM)\n", microtime(true)-$time, memory_get_peak_usage(true)/1024/1024);
-
-$count == $opts["n"] or printf("\nOnly %d finished\n", $count);
diff --git a/check_package-xml.php b/check_package-xml.php
deleted file mode 100755 (executable)
index 32a1e73..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-ini_set("log_errors", false);
-ini_set("display_errors", true);
-
-if ($argc > 1) {
-       if ($argv[1] === "-") {
-               $file = "php://stdin";
-       } else {
-               $file = $argv[1];
-       }
-} elseif (stdin_is_readable()) {
-       $file = "php://stdin";
-} else {
-       $file = "./package.xml";
-}
-
-if (($xml = simplexml_load_file($file))) {
-       $xml_files = xmllist($xml->contents[0]);
-       $dirs = ["."];
-       while ($dir = array_shift($dirs)) {
-               foreach (dirlist($dir) as $file) {
-                       if (is_gitignored($file)) {
-                               continue;
-                       }
-                       if (!is_dir($file)) {
-                               if (!in_array($file, $xml_files)) {
-                                       echo "Missing file $file\n";
-                               }
-                       } else {
-                               $base = basename($file);
-                               if ($base{0} !== ".") {
-                                       array_push($dirs, $file);
-                               }
-                       }
-               }
-       }
-       foreach ($xml_files as $file) {
-               if (!file_exists($file)) {
-                       echo "Extraneous file $file\n";
-               }
-       }
-}
-
-###
-
-function error($fmt) {
-       trigger_error(call_user_func_array("sprintf", func_get_args()));
-}
-
-function stdin_is_readable() {
-       $r = [STDIN]; $w = $e = [];
-       return stream_select($r, $w, $e, 0);
-}
-
-function is_gitignored($file) {
-       static $gitignore;
-       
-       if (!isset($gitignore)) {
-               if (is_readable(".gitignore")) {
-                       $gitignore = explode("\n", `find | git check-ignore --stdin`);
-               } else {
-                       $gitignore = false;
-               }
-       }
-       if ($gitignore) {
-               return in_array($file, $gitignore);
-       }
-       return false;
-}
-
-function xmllist(SimpleXmlElement $dir, $p = ".", &$a = null) {
-       settype($a, "array");
-       $p = trim($p, "/") . "/" . trim($dir["name"], "/") . "/";
-       foreach ($dir as $file) {
-               switch ($file->getName()) {
-                       case "dir":
-                               xmllist($file, $p, $a);
-                               break;
-                       case "file":
-                               $a[] = sprintf("%s/%s", trim($p, "/"), trim($file["name"]));
-                               break;
-                       default:
-                               error("Unknown content type: %s", $file->getName());
-                               break;
-               }
-       }
-       return $a;
-}
-
-function dirlist($dir, $p = null) {
-       $p = implode("/", array_filter([trim($p, "/"), trim($dir, "/")]));
-       foreach (scandir($p) as $file) {
-               yield $p."/".$file;
-       }
-}
index 13c24ab..4bd1f69 100644 (file)
-// config.w32 for pecl/http\r
-// $Id$\r
-\r
-ARG_ENABLE("http", "whether to enable extended HTTP support", "no");\r
-\r
-function check_for_main_ext(ext, header)\r
-{\r
-       if (!header) {\r
-               header = "php_"+ ext +".h";\r
-       }\r
-\r
-       /* When in configure, we're always in the root of PHP source */\r
-       var ext_path = "ext\\" + ext;\r
-       \r
-       STDOUT.Write("Checking for ext/"+ ext +" ...  ");\r
-\r
-       if (FSO.FileExists(ext_path + "\\" + header)) {\r
-               STDOUT.WriteLine(ext_path);\r
-               return ext_path;\r
-       }\r
-\r
-       STDOUT.WriteLine("<not found>");\r
-       return false;\r
-}\r
-\r
-function check_for_pecl_ext(ext, header)\r
-{\r
-       if (!header) {\r
-               header = "php_"+ ext +".h";\r
-       }\r
-       \r
-       var g;\r
-       var s = ext +"\\"+ header;\r
-       \r
-       STDOUT.Write("Checking for pecl/"+ ext +" ...  ");\r
-       if (    (g = glob(configure_module_dirname +"\\..\\"+ s)) ||\r
-                       (g = glob(configure_module_dirname +"\\..\\..\\..\\pecl\\"+ s))) {\r
-               var f = g[0].substr(0, g[0].length - header.length - 1);\r
-               STDOUT.WriteLine(f);\r
-               return f;\r
-       }\r
-       STDOUT.WriteLine("<not found>");\r
-       return false;\r
-}\r
-\r
-if (PHP_HTTP != "no") {\r
-\r
-       EXTENSION("http",\r
-               "php_http.c php_http_buffer.c php_http_client.c " +\r
-               "php_http_client_request.c php_http_client_response.c " +\r
-               "php_http_cookie.c php_http_curl.c php_http_client_curl.c " +\r
-               "php_http_encoding.c php_http_env.c php_http_env_request.c " +\r
-               "php_http_env_response.c php_http_etag.c php_http_exception.c php_http_filter.c php_http_header_parser.c " +\r
-               "php_http_header.c php_http_info.c php_http_message.c php_http_message_body.c php_http_message_parser.c " +\r
-               "php_http_misc.c php_http_negotiate.c php_http_object.c php_http_options.c php_http_params.c " +\r
-               "php_http_querystring.c php_http_url.c php_http_version.c",\r
-               null,\r
-               null);\r
-       AC_DEFINE("HAVE_HTTP", 1, "Have extended HTTP support");\r
-       AC_DEFINE("HTTP_SHARED_DEPS", 1, "Depend on shared extensions");\r
-       \r
-       AC_DEFINE("HAVE_GETHOSTNAME", 1);\r
-       \r
-       if (PHP_DEBUG != "no") {\r
-               ADD_FLAG("CFLAGS_HTTP", "/W3");\r
-       }\r
-       \r
-       if (CHECK_HEADER_ADD_INCLUDE('zlib.h', 'CFLAGS_HTTP', '..\\zlib;' + php_usual_include_suspects)) {\r
-               AC_DEFINE('HTTP_HAVE_ZLIB', 1, "Have zlib library");\r
-               ADD_FLAG("LDFLAGS_HTTP", "/FORCE:MULTIPLE");\r
-       } else {\r
-               WARNING("zlib encoding functions not enabled; libraries and headers not found");\r
-       }\r
-       \r
-       if (typeof(PHP_HASH) != "undefined" && PHP_HASH != "no") {\r
-               var f;\r
-               \r
-               if ((f = check_for_pecl_ext("hash")) || (f = check_for_main_ext("hash"))) {\r
-                       ADD_FLAG("CFLAGS_HTTP", '/I "' + f + '" /DHTTP_HAVE_PHP_HASH_H=1');\r
-                       ADD_EXTENSION_DEP("http", "hash", true);\r
-               }\r
-       }\r
-       \r
-       if (PHP_SESSION != "no") {\r
-               ADD_EXTENSION_DEP("http", "session", true);\r
-       }\r
-       \r
-       if (PHP_ICONV != "no") {\r
-               ADD_EXTENSION_DEP("http", "iconv", true);\r
-       }\r
-       \r
-       if (PHP_CURL != "no") {\r
-               ADD_EXTENSION_DEP("http", "curl", true);\r
-       }\r
-\r
-       \r
-       CURL_LIB="libcurl_a.lib;libcurl.lib;" + (PHP_DEBUG != "no" ? "libcurld.lib":"libcurl.lib");\r
-       if (CHECK_HEADER_ADD_INCLUDE("curl/curl.h", "CFLAGS_HTTP") &&\r
-                       CHECK_HEADER_ADD_INCLUDE("openssl/crypto.h", "CFLAGS_HTTP") &&\r
-                       CHECK_LIB(CURL_LIB, "http", PHP_HTTP) &&\r
-                       CHECK_LIB("ssleay32.lib", "http", PHP_HTTP) &&\r
-                       CHECK_LIB("libeay32.lib", "http", PHP_HTTP) &&\r
-                       CHECK_LIB("zlib.lib;zlib_a.lib", "http", PHP_HTTP) &&\r
-                       CHECK_LIB("libcurl_a.lib", "http", PHP_HTTP) &&\r
-                       ADD_EXTENSION_DEP("http", "propro", true) &&\r
-                       ADD_EXTENSION_DEP("http", "raphf", true) &&\r
-                       CHECK_LIB("winmm.lib", "http", PHP_HTTP)) {\r
-               AC_DEFINE("PHP_HTTP_HAVE_CURL", 1, "Have CURL library");\r
-               AC_DEFINE("PHP_HTTP_HAVE_SSL", 1, "Have SSL");\r
-               AC_DEFINE("PHP_HAVE_CURL_MULTI_STRERROR", 1, "");\r
-               AC_DEFINE("PHP_HAVE_CURL_SHARE_STRERROR", 1, "");\r
-               AC_DEFINE("PHP_HAVE_CURL_EASY_STRERROR", 1, "");\r
-               AC_DEFINE("PHP_HAVE_CURL_EASY_RESET", 1, "");\r
-               AC_DEFINE("PHP_HAVE_CURL_GETFORMDATA", 1, "");\r
-               AC_DEFINE("PHP_HAVE_CURL_FORMGET", 1, "");\r
-               AC_DEFINE("PHP_HAVE_CURL_MULTI_SETOPT", 1, "");\r
-               AC_DEFINE("PHP_HAVE_CURL_MULTI_TIMEOUT", 1, "");\r
-\r
-               if (CHECK_HEADER_ADD_INCLUDE("event2/event.h", "CFLAGS_HTTP") &&\r
-                       CHECK_LIB("libevent.lib", "http", PHP_HTTP) &&\r
-                       CHECK_LIB("libevent_core.lib", "http", PHP_HTTP) &&\r
-                       CHECK_LIB("libevent_extras.lib", "http", PHP_HTTP)) {\r
-\r
-                       AC_DEFINE("PHP_HTTP_HAVE_EVENT", 1);\r
-                       AC_DEFINE("PHP_HTTP_HAVE_EVENT2", 1);\r
-                       AC_DEFINE("PHP_HTTP_EVENT_VERSION", "2.0.21 or greater");\r
-               }\r
-       } else {\r
-               WARNING("curl convenience functions not enabled; libraries and headers not found");\r
-       }\r
-}\r
+// config.w32 for pecl/http
+// $Id$
+
+ARG_ENABLE("http", "whether to enable extended HTTP support", "no");
+
+function check_for_main_ext(ext, header)
+{
+       if (!header) {
+               header = "php_"+ ext +".h";
+       }
+
+       /* When in configure, we're always in the root of PHP source */
+       var ext_path = "ext\\" + ext;
+
+       STDOUT.Write("Checking for ext/"+ ext +" ...  ");
+
+       if (FSO.FileExists(ext_path + "\\" + header)) {
+               STDOUT.WriteLine(ext_path);
+               return ext_path;
+       }
+
+       STDOUT.WriteLine("<not found>");
+       return false;
+}
+
+function check_for_pecl_ext(ext, header)
+{
+       if (!header) {
+               header = "php_"+ ext +".h";
+       }
+
+       var g;
+       var s = ext +"\\"+ header;
+
+       STDOUT.Write("Checking for pecl/"+ ext +" ...  ");
+       if (    (g = glob(configure_module_dirname +"\\..\\"+ s)) ||
+                       (g = glob(configure_module_dirname +"\\..\\..\\..\\pecl\\"+ s))) {
+               var f = g[0].substr(0, g[0].length - header.length - 1);
+               STDOUT.WriteLine(f);
+               return f;
+       }
+       STDOUT.WriteLine("<not found>");
+       return false;
+}
+
+if (PHP_HTTP != "no") {
+
+       EXTENSION("http",
+               "src/php_http.c src/php_http_buffer.c src/php_http_client.c " +
+               "src/php_http_client_request.c src/php_http_client_response.c " +
+               "src/php_http_cookie.c src/php_http_curl.c src/php_http_client_curl.c " +
+               "src/php_http_encoding.c src/php_http_env.c src/php_http_env_request.c " +
+               "src/php_http_env_response.c src/php_http_etag.c src/php_http_exception.c src/php_http_filter.c src/php_http_header_parser.c " +
+               "src/php_http_header.c src/php_http_info.c src/php_http_message.c src/php_http_message_body.c src/php_http_message_parser.c " +
+               "src/php_http_misc.c src/php_http_negotiate.c src/php_http_object.c src/php_http_options.c src/php_http_params.c " +
+               "src/php_http_querystring.c src/php_http_url.c src/php_http_version.c",
+               null,
+               null);
+       AC_DEFINE("HAVE_HTTP", 1, "Have extended HTTP support");
+       AC_DEFINE("HTTP_SHARED_DEPS", 1, "Depend on shared extensions");
+
+       AC_DEFINE("HAVE_GETHOSTNAME", 1);
+
+       if (PHP_DEBUG != "no") {
+               ADD_FLAG("CFLAGS_HTTP", "/W3");
+       }
+
+       if (CHECK_HEADER_ADD_INCLUDE('zlib.h', 'CFLAGS_HTTP', '..\\zlib;' + php_usual_include_suspects)) {
+               AC_DEFINE('HTTP_HAVE_ZLIB', 1, "Have zlib library");
+               ADD_FLAG("LDFLAGS_HTTP", "/FORCE:MULTIPLE");
+       } else {
+               WARNING("zlib encoding functions not enabled; libraries and headers not found");
+       }
+
+       if (typeof(PHP_HASH) != "undefined" && PHP_HASH != "no") {
+               var f;
+
+               if ((f = check_for_pecl_ext("hash")) || (f = check_for_main_ext("hash"))) {
+                       ADD_FLAG("CFLAGS_HTTP", '/I "' + f + '" /DHTTP_HAVE_PHP_HASH_H=1');
+                       ADD_EXTENSION_DEP("http", "hash", true);
+               }
+       }
+
+       if (PHP_SESSION != "no") {
+               ADD_EXTENSION_DEP("http", "session", true);
+       }
+
+       if (PHP_ICONV != "no") {
+               ADD_EXTENSION_DEP("http", "iconv", true);
+       }
+
+       if (PHP_CURL != "no") {
+               ADD_EXTENSION_DEP("http", "curl", true);
+       }
+
+
+       CURL_LIB="libcurl_a.lib;libcurl.lib;" + (PHP_DEBUG != "no" ? "libcurld.lib":"libcurl.lib");
+       if (CHECK_HEADER_ADD_INCLUDE("curl/curl.h", "CFLAGS_HTTP") &&
+                       CHECK_HEADER_ADD_INCLUDE("openssl/crypto.h", "CFLAGS_HTTP") &&
+                       CHECK_LIB(CURL_LIB, "http", PHP_HTTP) &&
+                       CHECK_LIB("ssleay32.lib", "http", PHP_HTTP) &&
+                       CHECK_LIB("libeay32.lib", "http", PHP_HTTP) &&
+                       CHECK_LIB("zlib.lib;zlib_a.lib", "http", PHP_HTTP) &&
+                       CHECK_LIB("libcurl_a.lib", "http", PHP_HTTP) &&
+                       ADD_EXTENSION_DEP("http", "propro", true) &&
+                       ADD_EXTENSION_DEP("http", "raphf", true) &&
+                       CHECK_LIB("winmm.lib", "http", PHP_HTTP)) {
+               AC_DEFINE("PHP_HTTP_HAVE_CURL", 1, "Have CURL library");
+               AC_DEFINE("PHP_HTTP_HAVE_SSL", 1, "Have SSL");
+               AC_DEFINE("PHP_HAVE_CURL_MULTI_STRERROR", 1, "");
+               AC_DEFINE("PHP_HAVE_CURL_SHARE_STRERROR", 1, "");
+               AC_DEFINE("PHP_HAVE_CURL_EASY_STRERROR", 1, "");
+               AC_DEFINE("PHP_HAVE_CURL_EASY_RESET", 1, "");
+               AC_DEFINE("PHP_HAVE_CURL_GETFORMDATA", 1, "");
+               AC_DEFINE("PHP_HAVE_CURL_FORMGET", 1, "");
+               AC_DEFINE("PHP_HAVE_CURL_MULTI_SETOPT", 1, "");
+               AC_DEFINE("PHP_HAVE_CURL_MULTI_TIMEOUT", 1, "");
+
+               if (CHECK_HEADER_ADD_INCLUDE("event2/event.h", "CFLAGS_HTTP") &&
+                       CHECK_LIB("libevent.lib", "http", PHP_HTTP) &&
+                       CHECK_LIB("libevent_core.lib", "http", PHP_HTTP) &&
+                       CHECK_LIB("libevent_extras.lib", "http", PHP_HTTP)) {
+
+                       AC_DEFINE("PHP_HTTP_HAVE_EVENT", 1);
+                       AC_DEFINE("PHP_HTTP_HAVE_EVENT2", 1);
+                       AC_DEFINE("PHP_HTTP_EVENT_VERSION", "2.0.21 or greater");
+               }
+       } else {
+               WARNING("curl convenience functions not enabled; libraries and headers not found");
+       }
+}
index 273f038..da682f7 100644 (file)
@@ -31,22 +31,22 @@ if test "$PHP_HTTP" != "no"; then
                        AC_CHECK_PROG(SED, sed, sed)
                ])
        ])
-       
+
        AC_PROG_CPP
-       
+
        if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
                AC_DEFINE([PHP_HTTP_SHARED_DEPS], [1], [ ])
        else
                AC_DEFINE([PHP_HTTP_SHARED_DEPS], [0], [ ])
        fi
-       
+
        dnl
        dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
        dnl
        AC_DEFUN([HTTP_SHARED_DEP], [
                extname=$1
                haveext=$[PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
-               
+
                AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
                if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
                        AC_MSG_RESULT([no])
@@ -63,7 +63,7 @@ if test "$PHP_HTTP" != "no"; then
                        $3
                fi
        ])
-       
+
        dnl
        dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
        dnl
@@ -92,7 +92,7 @@ if test "$PHP_HTTP" != "no"; then
                        $3
                fi
        ])
-       
+
        dnl
        dnl HTTP_CURL_SSL_LIB_CHECK(ssllib[, code-if-yes[, code-if-not])
        dnl
@@ -120,7 +120,7 @@ if test "$PHP_HTTP" != "no"; then
                        $3
                ])
        ])
-       
+
 
 dnl ----
 dnl STDC
@@ -240,7 +240,7 @@ dnl ----
                        PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
                fi
        fi
-       
+
 dnl ----
 dnl CURL
 dnl ----
@@ -260,7 +260,7 @@ dnl ----
                        AC_MSG_RESULT([not found])
                else
                        AC_MSG_RESULT([found in $CURL_DIR])
-               
+
                        AC_MSG_CHECKING([for curl-config])
                        CURL_CONFIG=
                        for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
@@ -275,7 +275,7 @@ dnl ----
                        else
                                AC_MSG_RESULT([found: $CURL_CONFIG])
                        fi
-               
+
                        dnl RHEL6:         7.19.7
                        dnl SUSE11:        7.19.7
                        dnl Debian wheezy: 7.26.0
@@ -287,7 +287,7 @@ dnl ----
                        if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
                                AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
                        fi
-                       
+
                        AC_MSG_CHECKING([for HTTP2 support in libcurl])
                        if $CURL_CONFIG --features | $EGREP -q HTTP2; then
                                AC_MSG_RESULT([yes])
@@ -295,11 +295,11 @@ dnl ----
                        else
                                AC_MSG_RESULT([no])
                        fi
-               
+
                        dnl
                        dnl compile tests
                        dnl
-               
+
                        save_INCLUDES="$INCLUDES"
                        INCLUDES=
                        save_LIBS="$LIBS"
@@ -308,14 +308,14 @@ dnl ----
                        CFLAGS="$CFLAGS `$CURL_CONFIG --cflags`"
                        save_LDFLAGS="$LDFLAGS"
                        LDFLAGS="$ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
-               
+
                        AC_MSG_CHECKING([for SSL support in libcurl])
                        CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
                        CURL_SSL_LIBS=""
                        if test "$CURL_SSL" = "SSL"; then
                                AC_MSG_RESULT([yes])
                                AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ])
-                       
+
                                HTTP_CURL_SSL_LIB_CHECK(OpenSSL, [
                                        AC_CHECK_HEADER([openssl/ssl.h], [
                                                AC_CHECK_HEADER([openssl/crypto.h], [
@@ -345,7 +345,7 @@ dnl ----
                                dnl no CURL_SSL
                                AC_MSG_RESULT([no])
                        fi
-                       
+
                        AC_MSG_CHECKING([for ares support in libcurl])
                        AC_TRY_RUN([
                                #include <curl/curl.h>
@@ -364,7 +364,7 @@ dnl ----
                        ], [
                                AC_MSG_RESULT([no])
                        ])
-                       
+
                        AC_MSG_CHECKING([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP or literal "SRP"])
                        AC_TRY_RUN([
                                #include <curl/curl.h>
@@ -391,24 +391,24 @@ dnl ----
                                        AC_MSG_RESULT([neither])
                                ], [
                                        AC_MSG_RESULT([neither])
-                               ])                      
+                               ])
                        ], [
                                AC_MSG_RESULT([neither])
                        ])
-               
+
                        INCLUDES="$save_INCLUDES"
                        LIBS="$save_LIBS"
                        CFLAGS="$save_CFLAGS"
                        LDFLAGS="$save_LDFLAGS"
-                       
+
                        if test -n "$CURL_SSL_LIBS"; then
                                for CURL_SSL_LIB in $CURL_SSL_LIBS; do
                                        PHP_ADD_LIBRARY_WITH_PATH([$CURL_SSL_LIB], $CURL_DIR/$PHP_LIBDIR, PHP_HTTP_SHARED_LIBADD)
                                done
                        fi
-                       
+
                        dnl end compile tests
-               
+
                        AC_MSG_CHECKING([for bundled SSL CA info])
                        CURL_CAINFO=
                        for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt" "/etc/ssl/certs/ca-bundle.crt"; do
@@ -423,7 +423,7 @@ dnl ----
                                AC_MSG_RESULT([$CURL_CAINFO])
                                AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
                        fi
-               
+
                        PHP_ADD_INCLUDE($CURL_DIR/include)
                        PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
                        PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
@@ -453,9 +453,9 @@ dnl ----
                        AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
                else
                        AC_MSG_RESULT([found in $EVENT_DIR])
-                       
+
                        AC_MSG_CHECKING([for libevent version, roughly])
-                       
+
                        if test -f "$EVENT_DIR/include/event2/event.h"; then
                                EVENT_VER="`$AWK '/_EVENT_VERSION/ {gsub(/\"/,\"\",$3); print $3}' < $EVENT_DIR/include/event2/event-config.h`"
                                AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [1], [ ])
@@ -473,7 +473,7 @@ dnl ----
                        fi
                        AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
                        AC_MSG_RESULT([$EVENT_VER])
-                       
+
                        PHP_ADD_INCLUDE($EVENT_DIR/include)
                        PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
                        AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
@@ -573,90 +573,59 @@ dnl ----
 dnl ----
 dnl DONE
 dnl ----
+       PHP_ADD_INCLUDE(src)
+       PHP_ADD_BUILD_DIR(src)
        PHP_HTTP_SOURCES="\
-               php_http_buffer.c \
-               php_http.c \
-               php_http_client.c \
-               php_http_client_curl.c \
-               php_http_client_request.c \
-               php_http_client_response.c \
-               php_http_cookie.c \
-               php_http_curl.c \
-               php_http_encoding.c \
-               php_http_env.c \
-               php_http_env_request.c \
-               php_http_env_response.c \
-               php_http_etag.c \
-               php_http_exception.c \
-               php_http_filter.c \
-               php_http_header_parser.c \
-               php_http_header.c \
-               php_http_info.c \
-               php_http_message_body.c \
-               php_http_message.c \
-               php_http_message_parser.c \
-               php_http_misc.c \
-               php_http_negotiate.c \
-               php_http_object.c \
-               php_http_options.c \
-               php_http_params.c \
-               php_http_querystring.c \
-               php_http_url.c \
-               php_http_version.c \
+               src/php_http_buffer.c \
+               src/php_http.c \
+               src/php_http_client.c \
+               src/php_http_client_curl.c \
+               src/php_http_client_request.c \
+               src/php_http_client_response.c \
+               src/php_http_cookie.c \
+               src/php_http_curl.c \
+               src/php_http_encoding.c \
+               src/php_http_env.c \
+               src/php_http_env_request.c \
+               src/php_http_env_response.c \
+               src/php_http_etag.c \
+               src/php_http_exception.c \
+               src/php_http_filter.c \
+               src/php_http_header_parser.c \
+               src/php_http_header.c \
+               src/php_http_info.c \
+               src/php_http_message_body.c \
+               src/php_http_message.c \
+               src/php_http_message_parser.c \
+               src/php_http_misc.c \
+               src/php_http_negotiate.c \
+               src/php_http_object.c \
+               src/php_http_options.c \
+               src/php_http_params.c \
+               src/php_http_querystring.c \
+               src/php_http_url.c \
+               src/php_http_version.c \
        "
        PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
-       
+
        dnl shared extension deps
        HTTP_SHARED_DEP([hash])
        HTTP_SHARED_DEP([iconv])
-       
+
        dnl extension deps
        PHP_ADD_EXTENSION_DEP([http], [raphf], true)
        PHP_ADD_EXTENSION_DEP([http], [propro], true)
-       
+
        PHP_SUBST([HTTP_SHARED_LIBADD])
 
-       PHP_HTTP_HEADERS="
-               php_http_api.h \
-               php_http_buffer.h \
-               php_http_curl_client.h \
-               php_http_curl_client_datashare.h \
-               php_http_client_datashare.h \
-               php_http_client_factory.h \
-               php_http_client.h \
-               php_http_client_interface.h \
-               php_http_curl_client_pool.h \
-               php_http_client_pool.h \
-               php_http_client_request.h \
-               php_http_client_response.h \
-               php_http_cookie.h \
-               php_http_curl.h \
-               php_http_encoding.h \
-               php_http_env.h \
-               php_http_env_request.h \
-               php_http_env_response.h \
-               php_http_etag.h \
-               php_http_exception.h \
-               php_http_filter.h \
-               php_http.h \
-               php_http_header_parser.h \
-               php_http_header.h \
-               php_http_info.h \
-               php_http_message_body.h \
-               php_http_message.h \
-               php_http_message_parser.h \
-               php_http_misc.h \
-               php_http_negotiate.h \
-               php_http_object.h \
-               php_http_options.h \
-               php_http_params.h \
-               php_http_querystring.h \
-               php_http_response_codes.h \
-               php_http_url.h \
-               php_http_utf8.h \
-               php_http_version.h \
-       "
-       PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
+       PHP_HTTP_HEADERS=`(cd $ext_srcdir/src && echo *.h)`
+       PHP_INSTALL_HEADERS(ext/http, php_http.h $PHP_HTTP_HEADERS)
+       PHP_SUBST([PHP_HTTP_HEADERS])
+       PHP_HTTP_SRCDIR=$ext_srcdir
+       PHP_SUBST([PHP_HTTP_SRCDIR])
+       PHP_HTTP_BUILDDIR=$ext_builddir
+       PHP_SUBST([PHP_HTTP_BUILDDIR])
+       PHP_ADD_MAKEFILE_FRAGMENT
 
        AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
 fi
diff --git a/gen_curlinfo.php b/gen_curlinfo.php
deleted file mode 100755 (executable)
index 076a10d..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env php
-<?php
-// $Id: gen_curlinfo.php 323304 2012-02-17 21:13:24Z mike $
-
-error_reporting(0);
-
-function failure() {
-       // this is why error_get_last() should return a stdClass object
-       $error = error_get_last();
-       fprintf(STDERR, "FAILURE: %s\n", $error["message"]);
-       exit(-1);
-}
-
-function file_re($file, $pattern, $all = true) {
-       static $path;
-       
-       $path or $path = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1].'/include/curl/' : "/usr/local/include/curl/";
-       
-       if ($content = file_get_contents($path . $file)) {
-               if ($all) {
-                       if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) {
-                               return $matches;
-                       }
-               } else {
-                       if (preg_match($pattern, $content, $matches)) {
-                               return $matches;
-                       }
-               }
-               trigger_error("no match in $file for $pattern");
-       }
-       failure();
-}
-
-$ifdefs = array(
-       'PRIMARY_IP' => 'PHP_HTTP_CURL_VERSION(7,19,0)',
-       'APPCONNECT_TIME' => 'PHP_HTTP_CURL_VERSION(7,19,0)',
-    'CONDITION_UNMET' => 'PHP_HTTP_CURL_VERSION(7,19,4)',
-    'PRIMARY_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)',
-    'LOCAL_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)',
-    'LOCAL_IP' => 'PHP_HTTP_CURL_VERSION(7,21,0)',
-);
-$exclude = array(
-    'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH', 'CERTINFO', 'TLS_SESSION',
-    'RTSP_SESSION_ID', 'RTSP_CLIENT_CSEQ', 'RTSP_SERVER_CSEQ', 'RTSP_CSEQ_RECV',
-       'COOKIELIST'
-);
-
-$translate = array(
-       'HTTP_CONNECTCODE' => "connect_code",
-       'COOKIELIST' => 'cookies',
-);
-
-$templates = array(
-'STRING' => 
-'      if (CURLE_OK == curl_easy_getinfo(ch, %s, &c)) {
-               add_assoc_string_ex(&array, "%s", sizeof("%2$s"), c ? c : "", 1);
-       }
-',
-'DOUBLE' => 
-'      if (CURLE_OK == curl_easy_getinfo(ch, %s, &d)) {
-               add_assoc_double_ex(&array, "%s", sizeof("%2$s"), d);
-       }
-',
-'LONG' => 
-'      if (CURLE_OK == curl_easy_getinfo(ch, %s, &l)) {
-               add_assoc_long_ex(&array, "%s", sizeof("%2$s"), l);
-       }
-',
-'SLIST' =>
-'      if (CURLE_OK == curl_easy_getinfo(ch, %s, &s)) {
-               MAKE_STD_ZVAL(subarray);
-               array_init(subarray);
-               for (p = s; p; p = p->next) {
-                       if (p->data) {
-                               add_next_index_string(subarray, p->data, 1);
-                       }
-               }
-               add_assoc_zval_ex(&array, "%s", sizeof("%2$s"), subarray);
-               curl_slist_free_all(s);
-       }
-',
-);
-
-$infos = file_re('curl.h', '/^\s*(CURLINFO_(\w+))\s*=\s*CURLINFO_(STRING|LONG|DOUBLE|SLIST)\s*\+\s*\d+\s*,?\s*$/m');
-
-ob_start();
-foreach ($infos as $info) {
-       list(, $full, $short, $type) = $info;
-       if (in_array($short, $exclude)) continue;
-       if (isset($ifdefs[$short])) printf("#if %s\n", $ifdefs[$short]);
-       printf($templates[$type], $full, strtolower((isset($translate[$short])) ? $translate[$short] : $short));
-       if (isset($ifdefs[$short])) printf("#endif\n");
-}
-
-file_put_contents("php_http_client_curl.c", 
-       preg_replace('/(\/\* BEGIN::CURLINFO \*\/\n).*(\n\s*\/\* END::CURLINFO \*\/)/s', '$1'. ob_get_contents() .'$2',
-               file_get_contents("php_http_client_curl.c")));
-
-?>
diff --git a/gen_travis_yml.php b/gen_travis_yml.php
deleted file mode 100755 (executable)
index 89ab0b2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env php
-# autogenerated file; do not edit
-language: c
-
-addons:
- apt:
-  packages:
-   - php5-cli
-   - php-pear
-   - libcurl4-openssl-dev
-   - zlib1g-dev
-   - libidn11-dev
-   - libevent-dev
-
-env:
-<?php
-
-$gen = include "./travis/pecl/gen-matrix.php";
-$env = $gen([
-       "PHP" => ["5.4", "5.5", "5.6"],
-       "enable_debug",
-       "enable_maintainer_zts",
-       "enable_json",
-       "enable_hash" => ["yes"],
-       "enable_iconv" => ["yes"]
-]);
-foreach ($env as $e) {
-       printf(" - %s\n", $e);
-}
-
-?>
-
-before_script:
- - make -f travis/pecl/Makefile php
- - make -f travis/pecl/Makefile pecl PECL=raphf
- - make -f travis/pecl/Makefile pecl PECL=propro
-
-script:
- - make -f travis/pecl/Makefile ext PECL=http
- - make -f travis/pecl/Makefile test
-
-after_script:
- - test -e tests/helper/server.log && cat tests/helper/server.log
-
-sudo: false
diff --git a/gen_utf8.php b/gen_utf8.php
deleted file mode 100755 (executable)
index 865a2f5..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-error_reporting(E_ALL);
-set_error_handler(function($c, $e, $f, $l) {
-       throw new Exception("$e in $f on line $l");
-});
-
-$i18n = $argc >= 2 ? $argv[1] : "/usr/share/i18n/locales/i18n";
-
-$f = fopen($i18n, "r");
-$c = false;
-$a = false;
-
-ob_start(null, 0xffff);
-while (!feof($f)) {
-       $line = fgets($f);
-       if (!$c && $line !== "LC_CTYPE\n") {
-               continue;
-       }
-       $c = true;
-       if ($line === "END LC_CTYPE\n") {
-               break;
-       }
-       switch($line{0}) {
-       case "%":
-               break;
-       case "\n":
-               if ($a) {
-                       break 2;
-               }
-               break;
-       case " ":
-               if ($a) {
-                       foreach (explode(";", trim($line, "\n/ ;")) as $ranges) {
-                               $range = explode("..", $ranges);
-                               $step = 0;
-                               $end = 0;
-                               switch (count($range)) {
-                               case 3:
-                                       list($sstart, $sstep, $send) = $range;
-                                       sscanf($sstart, "<U%X>", $start);
-                                       sscanf($sstep, "(%d)", $step);
-                                       sscanf($send, "<U%X>", $end);
-
-                                       break;
-                               case 2:
-                                       list($sstart, $send) = $range;
-                                       $step = 1;
-                                       sscanf($sstart, "<U%X>", $start);
-                                       sscanf($send, "<U%X>", $end);
-                                       break;
-                               case 1:
-                                       list($sstart) = $range;
-                                       sscanf($sstart, "<U%X>", $start);
-                                       break;
-                               }
-                               print "\t{";
-                               if ($start >= 0xffff) {
-                                       printf("0x%08X, ", $start);
-                                       if ($end) {
-                                               printf("0x%08X, ", $end);
-                                       } else {
-                                               print("         0, ");
-                                       }
-                               } else {
-                                       printf("    0x%04X, ", $start);
-                                       if ($end) {
-                                               printf("    0x%04X, ", $end);
-                                       } else {
-                                               print("         0, ");
-                                       }
-                               }
-                               printf("%d},\n", $step);
-                       }
-               }
-               break;
-       default:
-               if ($a) {
-                       break 2;
-               } elseif ($line === "alpha /\n") {
-                       $a = true;
-               }
-               break;
-       }
-}
-
-file_put_contents("php_http_utf8.h",
-       preg_replace('/(\/\* BEGIN::UTF8TABLE \*\/\n).*(\n\s*\/\* END::UTF8TABLE \*\/)/s', '$1'. ob_get_contents() .'$2',
-               file_get_contents("php_http_utf8.h")));
index df97ad9..95578ea 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
+<?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"
  <channel>pecl.php.net</channel>
  <summary>Extended HTTP Support</summary>
  <description><![CDATA[
-This HTTP extension aims to provide a convenient and powerful 
+This HTTP extension aims to provide a convenient and powerful
 set of functionality for one of PHPs major applications.
 
-It eases handling of HTTP urls, headers and messages, provides 
-means for negotiation of a client's preferred content type, 
-language and charset, as well as a convenient way to send any 
+It eases handling of HTTP urls, headers and messages, provides
+means for negotiation of a client's preferred content type,
+language and charset, as well as a convenient way to send any
 arbitrary data with caching and resuming capabilities.
 
 It provides powerful request functionality with support for
@@ -44,84 +44,88 @@ http://dev.iworks.at/ext-http/lcov/ext/http/
   <release>stable</release>
   <api>stable</api>
  </stability>
- <license>BSD, revised</license>
+ <license uri="http://copyfree.org/content/standard/licenses/2bsd/license.txt">BSD-2-Clause</license>
  <notes><![CDATA[
 * Fixed gh-issue #12: crash on bad url passed to http\Message::setRequestUrl()
-* The URL parser now fails on empty labels 
+* The URL parser now fails on empty labels
 ]]></notes>
  <contents>
   <dir name="/">
-   <file role="doc" name="LICENSE"/>
+   <file role="doc" name="AUTHORS"/>
+   <file role="doc" name="BUGS"/>
+   <file role="doc" name="CONTRIBUTING.md"/>
    <file role="doc" name="CREDITS"/>
-   <file role="doc" name="Exceptions.txt"/>
-   <file role="doc" name="KnownIssues.txt"/>
-   <file role="doc" name="ThanksTo.txt"/>
+   <file role="doc" name="LICENSE"/>
+   <file role="doc" name="README.md"/>
+   <file role="doc" name="THANKS"/>
+   <file role="doc" name="TODO"/>
    <file role="src" name="config.m4"/>
    <file role="src" name="config9.m4"/>
    <file role="src" name="config.w32"/>
-   
-   <file role="src" name="php_http_api.h"/>
-   <file role="src" name="php_http_buffer.c"/>
-   <file role="src" name="php_http_buffer.h"/>
-   <file role="src" name="php_http.c"/>
-   <file role="src" name="php_http_client.c"/>
-   <file role="src" name="php_http_client.h"/>
-   <file role="src" name="php_http_client_curl.c"/>
-   <file role="src" name="php_http_client_curl.h"/>
-   <file role="src" name="php_http_client_request.c"/>
-   <file role="src" name="php_http_client_request.h"/>
-   <file role="src" name="php_http_client_response.c"/>
-   <file role="src" name="php_http_client_response.h"/>
-   <file role="src" name="php_http_cookie.c"/>
-   <file role="src" name="php_http_cookie.h"/>
-   <file role="src" name="php_http_curl.c"/>
-   <file role="src" name="php_http_curl.h"/>
-   <file role="src" name="php_http_encoding.c"/>
-   <file role="src" name="php_http_encoding.h"/>
-   <file role="src" name="php_http_env.c"/>
-   <file role="src" name="php_http_env.h"/>
-   <file role="src" name="php_http_env_request.c"/>
-   <file role="src" name="php_http_env_request.h"/>
-   <file role="src" name="php_http_env_response.c"/>
-   <file role="src" name="php_http_env_response.h"/>
-   <file role="src" name="php_http_etag.c"/>
-   <file role="src" name="php_http_etag.h"/>
-   <file role="src" name="php_http_exception.c"/>
-   <file role="src" name="php_http_exception.h"/>
-   <file role="src" name="php_http_filter.c"/>
-   <file role="src" name="php_http_filter.h"/>
+   <file role="src" name="Makefile.frag"/>
    <file role="src" name="php_http.h"/>
-   <file role="src" name="php_http_header_parser.c"/>
-   <file role="src" name="php_http_header_parser.h"/>
-   <file role="src" name="php_http_header.c"/>
-   <file role="src" name="php_http_header.h"/>
-   <file role="src" name="php_http_info.c"/>
-   <file role="src" name="php_http_info.h"/>
-   <file role="src" name="php_http_message_body.c"/>
-   <file role="src" name="php_http_message_body.h"/>
-   <file role="src" name="php_http_message.c"/>
-   <file role="src" name="php_http_message.h"/>
-   <file role="src" name="php_http_message_parser.c"/>
-   <file role="src" name="php_http_message_parser.h"/>
-   <file role="src" name="php_http_misc.c"/>
-   <file role="src" name="php_http_misc.h"/>
-   <file role="src" name="php_http_negotiate.c"/>
-   <file role="src" name="php_http_negotiate.h"/>
-   <file role="src" name="php_http_object.c"/>
-   <file role="src" name="php_http_object.h"/>
-   <file role="src" name="php_http_options.c"/>
-   <file role="src" name="php_http_options.h"/>
-   <file role="src" name="php_http_params.c"/>
-   <file role="src" name="php_http_params.h"/>
-   <file role="src" name="php_http_querystring.c"/>
-   <file role="src" name="php_http_querystring.h"/>
-   <file role="src" name="php_http_response_codes.h"/>
-   <file role="src" name="php_http_url.c"/>
-   <file role="src" name="php_http_url.h"/>
-   <file role="src" name="php_http_utf8.h"/>
-   <file role="src" name="php_http_version.c"/>
-   <file role="src" name="php_http_version.h"/>
-
+   <dir name="src">
+    <file role="src" name="php_http_api.h"/>
+    <file role="src" name="php_http_buffer.c"/>
+    <file role="src" name="php_http_buffer.h"/>
+    <file role="src" name="php_http.c"/>
+    <file role="src" name="php_http_client.c"/>
+    <file role="src" name="php_http_client.h"/>
+    <file role="src" name="php_http_client_curl.c"/>
+    <file role="src" name="php_http_client_curl.h"/>
+    <file role="src" name="php_http_client_request.c"/>
+    <file role="src" name="php_http_client_request.h"/>
+    <file role="src" name="php_http_client_response.c"/>
+    <file role="src" name="php_http_client_response.h"/>
+    <file role="src" name="php_http_cookie.c"/>
+    <file role="src" name="php_http_cookie.h"/>
+    <file role="src" name="php_http_curl.c"/>
+    <file role="src" name="php_http_curl.h"/>
+    <file role="src" name="php_http_encoding.c"/>
+    <file role="src" name="php_http_encoding.h"/>
+    <file role="src" name="php_http_env.c"/>
+    <file role="src" name="php_http_env.h"/>
+    <file role="src" name="php_http_env_request.c"/>
+    <file role="src" name="php_http_env_request.h"/>
+    <file role="src" name="php_http_env_response.c"/>
+    <file role="src" name="php_http_env_response.h"/>
+    <file role="src" name="php_http_etag.c"/>
+    <file role="src" name="php_http_etag.h"/>
+    <file role="src" name="php_http_exception.c"/>
+    <file role="src" name="php_http_exception.h"/>
+    <file role="src" name="php_http_filter.c"/>
+    <file role="src" name="php_http_filter.h"/>
+    <file role="src" name="php_http_header_parser.c"/>
+    <file role="src" name="php_http_header_parser.h"/>
+    <file role="src" name="php_http_header.c"/>
+    <file role="src" name="php_http_header.h"/>
+    <file role="src" name="php_http_info.c"/>
+    <file role="src" name="php_http_info.h"/>
+    <file role="src" name="php_http_message_body.c"/>
+    <file role="src" name="php_http_message_body.h"/>
+    <file role="src" name="php_http_message.c"/>
+    <file role="src" name="php_http_message.h"/>
+    <file role="src" name="php_http_message_parser.c"/>
+    <file role="src" name="php_http_message_parser.h"/>
+    <file role="src" name="php_http_misc.c"/>
+    <file role="src" name="php_http_misc.h"/>
+    <file role="src" name="php_http_negotiate.c"/>
+    <file role="src" name="php_http_negotiate.h"/>
+    <file role="src" name="php_http_object.c"/>
+    <file role="src" name="php_http_object.h"/>
+    <file role="src" name="php_http_options.c"/>
+    <file role="src" name="php_http_options.h"/>
+    <file role="src" name="php_http_params.c"/>
+    <file role="src" name="php_http_params.h"/>
+    <file role="src" name="php_http_querystring.c"/>
+    <file role="src" name="php_http_querystring.h"/>
+    <file role="src" name="php_http_response_codes.h"/>
+    <file role="src" name="php_http_url.c"/>
+    <file role="src" name="php_http_url.h"/>
+    <file role="src" name="php_http_utf8.h"/>
+    <file role="src" name="php_http_version.c"/>
+    <file role="src" name="php_http_version.h"/>
+   </dir>
    <dir name="tests">
     <file role="test" name="skipif.inc"/>
      <dir name="data">
@@ -329,6 +333,14 @@ http://dev.iworks.at/ext-http/lcov/ext/http/
      <file role="test" name="urlparser011.phpt"/>
      <file role="test" name="version001.phpt"/>
    </dir>
+   <dir name="scripts">
+    <file role="src" name="bench_select_vs_event.php"/>
+    <file role="src" name="check_package-xml.php"/>
+    <file role="src" name="gen_curlinfo.php"/>
+    <file role="src" name="gen_stubs.php"/>
+    <file role="src" name="gen_travis_yml.php"/>
+    <file role="src" name="gen_utf8.php"/>
+   </dir>
   </dir>
  </contents>
  <dependencies>
@@ -336,7 +348,7 @@ http://dev.iworks.at/ext-http/lcov/ext/http/
    <php>
     <min>5.3.0</min>
     <max>7.0.0</max>
-       <exclude>7.0.0</exclude>
+    <exclude>7.0.0</exclude>
    </php>
    <pearinstaller>
     <min>1.4.1</min>
@@ -345,12 +357,16 @@ http://dev.iworks.at/ext-http/lcov/ext/http/
     <name>raphf</name>
     <channel>pecl.php.net</channel>
     <min>1.1.0</min>
+    <max>2.0.0dev</max>
+    <exclude>2.0.0dev</exclude>
     <providesextension>raphf</providesextension>
    </package>
    <package>
     <name>propro</name>
     <channel>pecl.php.net</channel>
     <min>1.0.0</min>
+    <max>2.0.0dev</max>
+    <exclude>2.0.0dev</exclude>
     <providesextension>propro</providesextension>
    </package>
   </required>
diff --git a/php_http.c b/php_http.c
deleted file mode 100644 (file)
index 2ff20f1..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-#include <php_ini.h>
-#include <ext/standard/info.h>
-
-#include <zlib.h>
-
-#if PHP_HTTP_HAVE_CURL
-#      include <curl/curl.h>
-#      if PHP_HTTP_HAVE_EVENT
-#              if PHP_HTTP_HAVE_EVENT2
-#                      include <event2/event.h>
-#                      include <event2/event_struct.h>
-#              else
-#                      include <event.h>
-#              endif
-#      endif
-#endif
-#if PHP_HTTP_HAVE_IDN2
-#      include <idn2.h>
-#elif PHP_HTTP_HAVE_IDN
-#      include <idna.h>
-#endif
-
-ZEND_DECLARE_MODULE_GLOBALS(php_http);
-
-#ifdef COMPILE_DL_HTTP
-ZEND_GET_MODULE(http)
-#endif
-
-zend_function_entry http_functions[] = {
-       EMPTY_FUNCTION_ENTRY
-};
-
-PHP_MINIT_FUNCTION(http);
-PHP_MSHUTDOWN_FUNCTION(http);
-PHP_RSHUTDOWN_FUNCTION(http);
-PHP_MINFO_FUNCTION(http);
-
-static zend_module_dep http_module_deps[] = {
-       ZEND_MOD_REQUIRED("raphf")
-       ZEND_MOD_REQUIRED("propro")
-       ZEND_MOD_REQUIRED("spl")
-#ifdef PHP_HTTP_HAVE_HASH
-       ZEND_MOD_REQUIRED("hash")
-#endif
-#ifdef PHP_HTTP_HAVE_ICONV
-       ZEND_MOD_REQUIRED("iconv")
-#endif
-       {NULL, NULL, NULL, 0}
-};
-
-zend_module_entry http_module_entry = {
-       STANDARD_MODULE_HEADER_EX,
-       NULL,
-       http_module_deps,
-       "http",
-       http_functions,
-       PHP_MINIT(http),
-       PHP_MSHUTDOWN(http),
-       NULL,
-       PHP_RSHUTDOWN(http),
-       PHP_MINFO(http),
-       PHP_PECL_HTTP_VERSION,
-       STANDARD_MODULE_PROPERTIES
-};
-
-int http_module_number;
-
-#if PHP_DEBUG && !HAVE_GCOV
-void _dpf(int type, const char *data, size_t length)
-{
-       static const char _sym[] = "><><><";
-       if (type) {
-               int nwp = 0;
-               for (fprintf(stderr, "%c ", _sym[type-1]); length--; data++) {
-                       int ip = PHP_HTTP_IS_CTYPE(print, *data);
-                       if (!ip && *data != '\r' && *data != '\n') nwp = 1;
-                       fprintf(stderr, ip?"%c":"\\x%02x", (int) (*data & 0xff));
-                       if (!nwp && *data == '\n' && length) {
-                               fprintf(stderr, "\n%c ", _sym[type-1]);
-                       }
-               }
-               fprintf(stderr, "\n");
-       } else {
-               fprintf(stderr, "# %.*s\n", (int) length, data);
-       }
-}
-#endif
-
-static void php_http_globals_init_once(zend_php_http_globals *G)
-{
-       memset(G, 0, sizeof(*G));
-}
-
-#if 0
-static inline void php_http_globals_init(zend_php_http_globals *G TSRMLS_DC)
-{
-}
-
-static inline void php_http_globals_free(zend_php_http_globals *G TSRMLS_DC)
-{
-}
-#endif
-
-#if ZTS && PHP_DEBUG && !HAVE_GCOV
-zend_php_http_globals *php_http_globals(void)
-{
-       TSRMLS_FETCH();
-       return PHP_HTTP_G;
-}
-#endif
-
-PHP_INI_BEGIN()
-       STD_PHP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL, OnUpdateString, env.etag_mode, zend_php_http_globals, php_http_globals)
-PHP_INI_END()
-
-PHP_MINIT_FUNCTION(http)
-{
-       http_module_number = module_number;
-       ZEND_INIT_MODULE_GLOBALS(php_http, php_http_globals_init_once, NULL);
-       REGISTER_INI_ENTRIES();
-       
-       if (0
-       || SUCCESS != PHP_MINIT_CALL(http_exception)
-       || SUCCESS != PHP_MINIT_CALL(http_cookie)
-       || SUCCESS != PHP_MINIT_CALL(http_encoding)
-       || SUCCESS != PHP_MINIT_CALL(http_filter)
-       || SUCCESS != PHP_MINIT_CALL(http_header)
-       || SUCCESS != PHP_MINIT_CALL(http_header_parser)
-       || SUCCESS != PHP_MINIT_CALL(http_message)
-       || SUCCESS != PHP_MINIT_CALL(http_message_parser)
-       || SUCCESS != PHP_MINIT_CALL(http_message_body)
-       || SUCCESS != PHP_MINIT_CALL(http_querystring)
-       || SUCCESS != PHP_MINIT_CALL(http_client)
-       || SUCCESS != PHP_MINIT_CALL(http_client_request)
-       || SUCCESS != PHP_MINIT_CALL(http_client_response)
-#if PHP_HTTP_HAVE_CURL
-       || SUCCESS != PHP_MINIT_CALL(http_curl)
-       || SUCCESS != PHP_MINIT_CALL(http_client_curl)
-#endif
-       || SUCCESS != PHP_MINIT_CALL(http_url)
-       || SUCCESS != PHP_MINIT_CALL(http_env)
-       || SUCCESS != PHP_MINIT_CALL(http_env_request)
-       || SUCCESS != PHP_MINIT_CALL(http_env_response)
-       || SUCCESS != PHP_MINIT_CALL(http_params)
-       ) {
-               return FAILURE;
-       }
-       
-       return SUCCESS;
-}
-
-
-
-PHP_MSHUTDOWN_FUNCTION(http)
-{
-       UNREGISTER_INI_ENTRIES();
-       
-       if (0
-       || SUCCESS != PHP_MSHUTDOWN_CALL(http_message)
-#if PHP_HTTP_HAVE_CURL
-       || SUCCESS != PHP_MSHUTDOWN_CALL(http_client_curl)
-       || SUCCESS != PHP_MSHUTDOWN_CALL(http_curl)
-#endif
-       || SUCCESS != PHP_MSHUTDOWN_CALL(http_client)
-       ) {
-               return FAILURE;
-       }
-       
-       return SUCCESS;
-}
-
-PHP_RSHUTDOWN_FUNCTION(http)
-{
-       if (0
-       || SUCCESS != PHP_RSHUTDOWN_CALL(http_env)
-       ) {
-               return FAILURE;
-       }
-       
-       return SUCCESS;
-}
-
-PHP_MINFO_FUNCTION(http)
-{
-       php_http_buffer_t buf;
-
-       php_http_buffer_init(&buf);
-
-       php_info_print_table_start();
-       php_info_print_table_header(2, "HTTP Support", "enabled");
-       php_info_print_table_row(2, "Extension Version", PHP_PECL_HTTP_VERSION);
-       php_info_print_table_end();
-       
-       php_info_print_table_start();
-       php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
-       php_info_print_table_row(3, "libz", ZLIB_VERSION, zlibVersion());
-#if PHP_HTTP_HAVE_CURL
-       {
-               curl_version_info_data *cv = curl_version_info(CURLVERSION_NOW);
-               php_info_print_table_row(3, "libcurl", LIBCURL_VERSION, cv->version);
-       }
-#else
-       php_info_print_table_row(3, "libcurl", "disabled", "disabled");
-#endif
-
-#if PHP_HTTP_HAVE_EVENT
-       php_info_print_table_row(3, "libevent",
-#      ifdef LIBEVENT_VERSION
-                       LIBEVENT_VERSION,
-#      else
-                       PHP_HTTP_EVENT_VERSION,
-#      endif
-                       event_get_version());
-#else
-       php_info_print_table_row(3, "libevent", "disabled", "disabled");
-#endif
-
-#if PHP_HTTP_HAVE_IDN2
-       php_info_print_table_row(3, "libidn2 (IDNA2008)", IDN2_VERSION, idn2_check_version(NULL));
-#elif PHP_HTTP_HAVE_IDN
-       php_info_print_table_row(3, "libidn (IDNA2003)", PHP_HTTP_LIBIDN_VERSION, "unknown");
-#endif
-
-       php_info_print_table_end();
-       
-       DISPLAY_INI_ENTRIES();
-}
-
-
-/*
- * 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
- */
-
diff --git a/php_http_api.h b/php_http_api.h
deleted file mode 100644 (file)
index 08b6ba8..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_API_H
-#define PHP_HTTP_API_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifndef PHP_WIN32
-#include <php_config.h>
-#endif
-#include <php.h>
-#include <SAPI.h>
-
-#include <ext/raphf/php_raphf.h>
-#include <ext/propro/php_propro.h>
-#include <ext/standard/php_string.h>
-#include <ext/spl/spl_iterators.h>
-#include <ext/date/php_date.h>
-
-#include <zend_interfaces.h>
-#include <zend_exceptions.h>
-
-
-#ifdef PHP_WIN32
-# define PHP_HTTP_API __declspec(dllexport)
-#elif defined(__GNUC__) && __GNUC__ >= 4
-# define PHP_HTTP_API extern __attribute__ ((visibility("default")))
-#else
-# define PHP_HTTP_API extern
-#endif
-
-#if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
-#      define PHP_HTTP_HAVE_ICONV
-#endif
-
-#if (defined(HAVE_HASH_EXT) || defined(PHP_HTTP_HAVE_EXT_HASH)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(PHP_HTTP_HAVE_PHP_HASH_H)
-#      define PHP_HTTP_HAVE_HASH
-#endif
-
-#include <stddef.h>
-
-#ifdef PHP_WIN32
-#      define CURL_STATICLIB
-#      include <winsock2.h>
-#else
-#      ifdef HAVE_NETDB_H
-#              include <netdb.h>
-#      endif
-#      ifdef HAVE_UNISTD_H
-#              include <unistd.h>
-#      endif
-#endif
-
-#if defined(HAVE_WCHAR_H) && defined(HAVE_WCTYPE_H) && defined(HAVE_ISWALNUM) && (defined(HAVE_MBRTOWC) || defined(HAVE_MBTOWC))
-#      define PHP_HTTP_HAVE_WCHAR 1
-#endif
-
-#include <ctype.h>
-#define PHP_HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c))
-#define PHP_HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c))
-
-#include "php_http.h"
-
-#include "php_http_buffer.h"
-#include "php_http_misc.h"
-#include "php_http_options.h"
-
-#include "php_http.h"
-#include "php_http_cookie.h"
-#include "php_http_encoding.h"
-#include "php_http_info.h"
-#include "php_http_message.h"
-#include "php_http_env.h"
-#include "php_http_env_request.h"
-#include "php_http_env_response.h"
-#include "php_http_etag.h"
-#include "php_http_exception.h"
-#include "php_http_filter.h"
-#include "php_http_header_parser.h"
-#include "php_http_header.h"
-#include "php_http_message_body.h"
-#include "php_http_message_parser.h"
-#include "php_http_negotiate.h"
-#include "php_http_object.h"
-#include "php_http_params.h"
-#include "php_http_querystring.h"
-#include "php_http_client.h"
-#include "php_http_curl.h"
-#include "php_http_client_request.h"
-#include "php_http_client_response.h"
-#include "php_http_client_curl.h"
-#include "php_http_url.h"
-#include "php_http_version.h"
-
-ZEND_BEGIN_MODULE_GLOBALS(php_http)
-       struct php_http_env_globals env;
-ZEND_END_MODULE_GLOBALS(php_http)
-
-ZEND_EXTERN_MODULE_GLOBALS(php_http);
-
-#ifdef ZTS
-#      include "TSRM/TSRM.h"
-#      define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)])
-#      undef TSRMLS_FETCH_FROM_CTX
-#      define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = ((ctx)?(ctx):ts_resource_ex(0, NULL))
-#else
-#      define PHP_HTTP_G (&php_http_globals)
-#endif
-
-#if PHP_DEBUG
-#      define _DPF_STR 0
-#      define _DPF_IN  1
-#      define _DPF_OUT 2
-extern void _dpf(int type, const char *data, size_t length);
-#else
-#      define _dpf(t,s,l);
-#endif
-
-#endif /* PHP_HTTP_API_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
- */
diff --git a/php_http_buffer.c b/php_http_buffer.c
deleted file mode 100644 (file)
index e24a4e1..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include <php.h>
-#include "php_http_buffer.h"
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, int flags)
-{
-       if (!buf) {
-               buf = pemalloc(sizeof(*buf), flags & PHP_HTTP_BUFFER_INIT_PERSISTENT);
-       }
-
-       if (buf) {
-               buf->size = (chunk_size) ? chunk_size : PHP_HTTP_BUFFER_DEFAULT_SIZE;
-               buf->pmem = (flags & PHP_HTTP_BUFFER_INIT_PERSISTENT) ? 1 : 0;
-               buf->data = (flags & PHP_HTTP_BUFFER_INIT_PREALLOC) ? pemalloc(buf->size, buf->pmem) : NULL;
-               buf->free = (flags & PHP_HTTP_BUFFER_INIT_PREALLOC) ? buf->size : 0;
-               buf->used = 0;
-       }
-       
-       return buf;
-}
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_buffer_t *buf, const char *string, size_t length)
-{
-       if ((buf = php_http_buffer_init(buf))) {
-               if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, string, length)) {
-                       pefree(buf, buf->pmem);
-                       buf = NULL;
-               }
-       }
-       return buf;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, size_t len, size_t override_size, int allow_error)
-{
-       char *ptr = NULL;
-#if 0
-       fprintf(stderr, "RESIZE: len=%lu, size=%lu, used=%lu, free=%lu, total=%lu\n", len, buf->size, buf->used, buf->free, buf->free+buf->used);
-#endif
-       if (buf->free < len) {
-               size_t size = override_size ? override_size : buf->size;
-               
-               while ((size + buf->free) < len) {
-                       size <<= 1;
-               }
-               
-               if (allow_error) {
-                       ptr = perealloc_recoverable(buf->data, buf->used + buf->free + size, buf->pmem);
-               } else {
-                       ptr = perealloc(buf->data, buf->used + buf->free + size, buf->pmem);
-               }
-               
-               if (ptr) {
-                       buf->data = ptr;
-               } else {
-                       return PHP_HTTP_BUFFER_NOMEM;
-               }
-               
-               buf->free += size;
-               return size;
-       }
-       return 0;
-}
-
-PHP_HTTP_BUFFER_API char *php_http_buffer_account(php_http_buffer_t *buf, size_t to_account)
-{
-       assert(to_account <= buf->free);
-
-       buf->free -= to_account;
-       buf->used += to_account;
-
-       return buf->data + buf->used;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_shrink(php_http_buffer_t *buf)
-{
-       /* avoid another realloc on fixation */
-       if (buf->free > 1) {
-               char *ptr = perealloc(buf->data, buf->used + 1, buf->pmem);
-               
-               if (ptr) {
-                       buf->data = ptr;
-               } else {
-                       return PHP_HTTP_BUFFER_NOMEM;
-               }
-               buf->free = 1;
-       }
-       return buf->used;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_append(php_http_buffer_t *buf, const char *append, size_t append_len)
-{
-       if (buf->free < append_len && PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, append_len)) {
-               return PHP_HTTP_BUFFER_NOMEM;
-       }
-       memcpy(buf->data + buf->used, append, append_len);
-       buf->used += append_len;
-       buf->free -= append_len;
-       return append_len;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_appendf(php_http_buffer_t *buf, const char *format, ...)
-{
-       va_list argv;
-       char *append;
-       size_t append_len, alloc;
-
-       va_start(argv, format);
-       append_len = vspprintf(&append, 0, format, argv);
-       va_end(argv);
-
-       alloc = php_http_buffer_append(buf, append, append_len);
-       efree(append);
-
-       if (PHP_HTTP_BUFFER_NOMEM == alloc) {
-               return PHP_HTTP_BUFFER_NOMEM;
-       }
-       return append_len;
-}
-
-PHP_HTTP_BUFFER_API char *php_http_buffer_data(const php_http_buffer_t *buf, char **into, size_t *len)
-{
-       char *copy = ecalloc(1, buf->used + 1);
-       memcpy(copy, buf->data, buf->used);
-       if (into) {
-               *into = copy;
-       }
-       if (len) {
-               *len = buf->used;
-       }
-       return copy;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_cut(php_http_buffer_t *buf, size_t offset, size_t length)
-{
-       if (offset > buf->used) {
-               return 0;
-       }
-       if (offset + length > buf->used) {
-               length = buf->used - offset;
-       }
-       memmove(buf->data + offset, buf->data + offset + length, buf->used - length - offset);
-       buf->used -= length;
-       buf->free += length;
-       return length;
-}
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_fix(php_http_buffer_t *buf)
-{
-       if (buf->free < 1 && PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize_ex(buf, 1, 1, 0)) {
-               return NULL;
-       }
-       buf->data[buf->used] = '\0';
-       return buf;
-}
-
-PHP_HTTP_BUFFER_API void php_http_buffer_reset(php_http_buffer_t *buf)
-{
-       buf->free += buf->used;
-       buf->used = 0;
-}
-
-PHP_HTTP_BUFFER_API void php_http_buffer_dtor(php_http_buffer_t *buf)
-{
-       if (buf->data) {
-               pefree(buf->data, buf->pmem);
-               buf->data = NULL;
-       }
-       buf->used = 0;
-       buf->free = 0;
-}
-
-PHP_HTTP_BUFFER_API void php_http_buffer_free(php_http_buffer_t **buf)
-{
-       if (*buf) {
-               php_http_buffer_dtor(*buf);
-               pefree(*buf, (*buf)->pmem);
-               *buf = NULL;
-       }
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunk_buffer(php_http_buffer_t **s, const char *data, size_t data_len, char **chunk, size_t chunk_size)
-{
-       php_http_buffer_t *storage;
-       
-       *chunk = NULL;
-       
-       if (!*s) {
-               *s = php_http_buffer_init_ex(NULL, chunk_size << 1, chunk_size ? PHP_HTTP_BUFFER_INIT_PREALLOC : 0);
-       }
-       storage = *s;
-       
-       if (data_len) {
-               php_http_buffer_append(storage, data, data_len);
-       }
-       
-       if (!chunk_size) {
-               php_http_buffer_data(storage, chunk, &chunk_size);
-               php_http_buffer_free(s);
-               return chunk_size;
-       }
-       
-       if (storage->used >= chunk_size) {
-               *chunk = estrndup(storage->data, chunk_size);
-               php_http_buffer_cut(storage, 0, chunk_size);
-               return chunk_size;
-       }
-       
-       return 0;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s, const char *data, size_t data_len, size_t chunk_len, php_http_buffer_pass_func_t passout, void *opaque TSRMLS_DC)
-{
-       char *chunk = NULL;
-       size_t passed = 0, got = 0;
-
-       while ((got = php_http_buffer_chunk_buffer(s, data, data_len, &chunk, chunk_len))) {
-               if (PHP_HTTP_BUFFER_PASS0 == passout(opaque, chunk, got TSRMLS_CC)) {
-                       PTR_SET(chunk, NULL);
-                       return PHP_HTTP_BUFFER_PASS0;
-               }
-               ++passed;
-               if (!chunk_len) {
-                       /*      we already got the last chunk,
-                               and freed all resources */
-                       break;
-               }
-               data = NULL;
-               data_len = 0;
-               PTR_SET(chunk, NULL);
-       }
-       PTR_FREE(chunk);
-       return passed;
-}
-
-PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *passin_arg, php_http_buffer_pass_func_t passon, void *passon_arg TSRMLS_DC)
-{
-       size_t passed_on = 0, passed_in = php_http_buffer_chunked_input(s, chunk_size, passin, passin_arg TSRMLS_CC);
-
-       if (passed_in == PHP_HTTP_BUFFER_PASS0) {
-               return passed_in;
-       }
-       if (passed_in || (*s)->used) {
-               passed_on = passon(passon_arg, (*s)->data, (*s)->used TSRMLS_CC);
-
-               if (passed_on == PHP_HTTP_BUFFER_PASS0) {
-                       return passed_on;
-               }
-
-               if (passed_on) {
-                       php_http_buffer_cut(*s, 0, passed_on);
-               }
-       }
-
-       return passed_on - passed_in;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_input(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *opaque TSRMLS_DC)
-{
-       php_http_buffer_t *str;
-       size_t passed;
-
-       if (!*s) {
-               *s = php_http_buffer_init_ex(NULL, chunk_size, chunk_size ? PHP_HTTP_BUFFER_INIT_PREALLOC : 0);
-       }
-       str = *s;
-
-       php_http_buffer_resize(str, chunk_size);
-       passed = passin(opaque, str->data + str->used, chunk_size TSRMLS_CC);
-
-       if (passed != PHP_HTTP_BUFFER_PASS0) {
-               str->used += passed;
-               str->free -= passed;
-       }
-
-       php_http_buffer_fix(str);
-
-       return passed;
-}
-
-#ifdef PHP_HTTP_BUFFER_EXTENDED
-
-PHP_HTTP_BUFFER_API int php_http_buffer_cmp(php_http_buffer_t *left, php_http_buffer_t *right)
-{
-       if (left->used > right->used) {
-               return -1;
-       } else if (right->used > left->used) {
-               return 1;
-       } else {
-               return memcmp(left->data, right->data, left->used);
-       }
-}
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_copy(const php_http_buffer_t *from, php_http_buffer_t *to)
-{
-       int free_to = !to;
-
-       to = php_http_buffer_clone(from, to);
-
-       if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(to, from->data, from->used)) {
-               if (free_to) {
-                       php_http_buffer_free(&to);
-               } else {
-                       php_http_buffer_dtor(to);
-               }
-       }
-       return to;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_insert(php_http_buffer_t *buf, const char *insert, size_t insert_len, size_t offset)
-{
-       if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, insert_len)) {
-               return PHP_HTTP_BUFFER_NOMEM;
-       }
-       memmove(buf->data + offset + insert_len, buf->data + offset, insert_len);
-       memcpy(buf->data + offset, insert, insert_len);
-       buf->used += insert_len;
-       buf->free -= insert_len;
-       return insert_len;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_insertf(php_http_buffer_t *buf, size_t offset, const char *format, ...)
-{
-       va_list argv;
-       char *insert;
-       size_t insert_len, alloc;
-
-       va_start(argv, format);
-       insert_len = vspprintf(&insert, 0, format, argv);
-       va_end(argv);
-
-       alloc = php_http_buffer_insert(buf, insert, insert_len, offset);
-       efree(insert);
-
-       if (PHP_HTTP_BUFFER_NOMEM == alloc) {
-               return PHP_HTTP_BUFFER_NOMEM;
-       }
-       return insert_len;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_prepend(php_http_buffer_t *buf, const char *prepend, size_t prepend_len)
-{
-       if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, prepend_len)) {
-               return PHP_HTTP_BUFFER_NOMEM;
-       }
-       memmove(buf->data + prepend_len, buf->data, buf->used);
-       memcpy(buf->data, prepend, prepend_len);
-       buf->used += prepend_len;
-       buf->free -= prepend_len;
-       return prepend_len;
-}
-
-PHP_HTTP_BUFFER_API size_t php_http_buffer_prependf(php_http_buffer_t *buf, const char *format, ...)
-{
-       va_list argv;
-       char *prepend;
-       size_t prepend_len, alloc;
-
-       va_start(argv, format);
-       prepend_len = vspprintf(&prepend, 0, format, argv);
-       va_end(argv);
-
-       alloc = php_http_buffer_prepend(buf, prepend, prepend_len);
-       efree(prepend);
-
-       if (PHP_HTTP_BUFFER_NOMEM == alloc) {
-               return PHP_HTTP_BUFFER_NOMEM;
-       }
-       return prepend_len;
-}
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_sub(const php_http_buffer_t *buf, size_t offset, size_t length)
-{
-       if (offset >= buf->used) {
-               return NULL;
-       } else {
-               size_t need = 1 + ((length + offset) > buf->used ? (buf->used - offset) : (length - offset));
-               php_http_buffer_t *sub = php_http_buffer_init_ex(NULL, need, PHP_HTTP_BUFFER_INIT_PREALLOC | (buf->pmem ? PHP_HTTP_BUFFER_INIT_PERSISTENT:0));
-               if (sub) {
-                       if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(sub, buf->data + offset, need)) {
-                               php_http_buffer_free(&sub);
-                       } else {
-                               sub->size = buf->size;
-                       }
-               }
-               return sub;
-       }
-}
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_right(const php_http_buffer_t *buf, size_t length)
-{
-       if (length < buf->used) {
-               return php_http_buffer_sub(buf, buf->used - length, length);
-       } else {
-               return php_http_buffer_sub(buf, 0, buf->used);
-       }
-}
-
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_va(php_http_buffer_t *buf, unsigned argc, va_list argv)
-{
-       unsigned i = 0;
-       buf = php_http_buffer_init(buf);
-
-       if (buf) {
-               while (argc > i++) {
-                       php_http_buffer_free_t f = va_arg(argv, php_http_buffer_free_t);
-                       php_http_buffer_t *current = va_arg(argv, php_http_buffer_t *);
-                       php_http_buffer_append(buf, current->data, current->used);
-                       FREE_PHP_HTTP_BUFFER(f, current);
-               }
-       }
-
-       return buf;
-}
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_ex(php_http_buffer_t *buf, unsigned argc, ...)
-{
-       va_list argv;
-       php_http_buffer_t *ret;
-
-       va_start(argv, argc);
-       ret = php_http_buffer_merge_va(buf, argc, argv);
-       va_end(argv);
-       return ret;
-}
-
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge(unsigned argc, ...)
-{
-       va_list argv;
-       php_http_buffer_t *ret;
-
-       va_start(argv, argc);
-       ret = php_http_buffer_merge_va(NULL, argc, argv);
-       va_end(argv);
-       return ret;
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
-
diff --git a/php_http_buffer.h b/php_http_buffer.h
deleted file mode 100644 (file)
index faf8992..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_BUFFER_H
-#define PHP_HTTP_BUFFER_H
-
-#ifndef PHP_HTTP_BUFFER_DEFAULT_SIZE
-#      define PHP_HTTP_BUFFER_DEFAULT_SIZE 256
-#endif
-
-#define PHP_HTTP_BUFFER_ERROR ((size_t) -1)
-#define PHP_HTTP_BUFFER_NOMEM PHP_HTTP_BUFFER_ERROR
-#define PHP_HTTP_BUFFER_PASS0 PHP_HTTP_BUFFER_ERROR
-
-#ifndef PTR_FREE
-#      define PTR_FREE(PTR) \
-       { \
-               if (PTR) { \
-                       efree(PTR); \
-               } \
-       }
-#endif
-#ifndef PTR_SET
-#      define PTR_SET(PTR, SET) \
-       { \
-               PTR_FREE(PTR); \
-               PTR = SET; \
-       }
-#endif
-#ifndef TSRMLS_D
-#      define TSRMLS_D
-#      define TSRMLS_DC
-#      define TSRMLS_CC
-#      define TSRMLS_C
-#endif
-#ifdef PHP_ATTRIBUTE_FORMAT
-#      define PHP_HTTP_BUFFER_ATTRIBUTE_FORMAT(f, a, b) PHP_ATTRIBUTE_FORMAT(f, a, b)
-#else
-#      define PHP_HTTP_BUFFER_ATTRIBUTE_FORMAT(f, a, b)
-#endif
-#ifndef pemalloc
-#      define pemalloc(s,p)    malloc(s)
-#      define pefree(x,p)              free(x)
-#      define perealloc(x,s,p) realloc(x,s)
-#      define perealloc_recoverable perealloc
-#      define ecalloc calloc
-static inline void *estrndup(void *p, size_t s)
-{
-       char *r = (char *) malloc(s+1);
-       if (r) memcpy((void *) r, p, s), r[s] = '\0';
-       return (void *) r;
-}
-#endif
-
-#if defined(PHP_WIN32)
-#      if defined(PHP_HTTP_BUFFER_EXPORTS)
-#              define PHP_HTTP_BUFFER_API __declspec(dllexport)
-#      elif defined(COMPILE_DL_PHP_HTTP_BUFFER)
-#              define PHP_HTTP_BUFFER_API __declspec(dllimport)
-#      else
-#              define PHP_HTTP_BUFFER_API
-#      endif
-#else
-#      define PHP_HTTP_BUFFER_API
-#endif
-
-#define PHP_HTTP_BUFFER(p) ((php_http_buffer_t *) (p))
-
-#define FREE_PHP_HTTP_BUFFER_PTR(STR) pefree(STR, STR->pmem)
-#define FREE_PHP_HTTP_BUFFER_VAL(STR) php_http_buffer_dtor(STR)
-#define FREE_PHP_HTTP_BUFFER_ALL(STR) php_http_buffer_free(&(STR))
-#define FREE_PHP_HTTP_BUFFER(free, STR) \
-       switch (free) \
-       { \
-       case PHP_HTTP_BUFFER_FREE_NOT: \
-               break; \
-       case PHP_HTTP_BUFFER_FREE_PTR: \
-               pefree(STR, STR->pmem); break; \
-               break; \
-       case PHP_HTTP_BUFFER_FREE_VAL: \
-               php_http_buffer_dtor(STR); \
-               break; \
-       case PHP_HTTP_BUFFER_FREE_ALL: { \
-               php_http_buffer_t *PTR = (STR); \
-               php_http_buffer_free(&PTR); \
-               break; \
-       } \
-       default:\
-               break; \
-       }
-
-#define RETURN_PHP_HTTP_BUFFER_PTR(STR) RETURN_PHP_HTTP_BUFFER((STR), PHP_HTTP_BUFFER_FREE_PTR, 0)
-#define RETURN_PHP_HTTP_BUFFER_VAL(STR) RETURN_PHP_HTTP_BUFFER((STR), PHP_HTTP_BUFFER_FREE_NOT, 0)
-#define RETURN_PHP_HTTP_BUFFER_DUP(STR) RETURN_PHP_HTTP_BUFFER((STR), PHP_HTTP_BUFFER_FREE_NOT, 1)
-#define RETVAL_PHP_HTTP_BUFFER_PTR(STR) RETVAL_PHP_HTTP_BUFFER((STR), PHP_HTTP_BUFFER_FREE_PTR, 0)
-#define RETVAL_PHP_HTTP_BUFFER_VAL(STR) RETVAL_PHP_HTTP_BUFFER((STR), PHP_HTTP_BUFFER_FREE_NOT, 0)
-#define RETVAL_PHP_HTTP_BUFFER_DUP(STR) RETVAL_PHP_HTTP_BUFFER((STR), PHP_HTTP_BUFFER_FREE_NOT, 1)
-/* RETURN_PHP_HTTP_BUFFER(buf, PHP_HTTP_BUFFER_FREE_PTR, 0) */
-#define RETURN_PHP_HTTP_BUFFER(STR, free, dup) \
-       RETVAL_PHP_HTTP_BUFFER((STR), (free), (dup)); \
-       return;
-
-#define RETVAL_PHP_HTTP_BUFFER(STR, free, dup) \
-       php_http_buffer_fix(STR); \
-       RETVAL_STRINGL((STR)->data, (STR)->used, (dup)); \
-       FREE_PHP_HTTP_BUFFER((free), (STR));
-
-typedef struct php_http_buffer {
-       char  *data;
-       size_t used;
-       size_t free;
-       size_t size;
-       unsigned pmem:1;
-       unsigned reserved:31;
-} php_http_buffer_t;
-
-typedef enum php_http_buffer_free {
-       PHP_HTTP_BUFFER_FREE_NOT = 0,
-       PHP_HTTP_BUFFER_FREE_PTR,       /* pefree() */
-       PHP_HTTP_BUFFER_FREE_VAL,       /* php_http_buffer_dtor() */
-       PHP_HTTP_BUFFER_FREE_ALL        /* php_http_buffer_free() */
-} php_http_buffer_free_t;
-
-#define PHP_HTTP_BUFFER_ALL_FREE(STR) PHP_HTTP_BUFFER_FREE_ALL,(STR)
-#define PHP_HTTP_BUFFER_PTR_FREE(STR) PHP_HTTP_BUFFER_FREE_PTR,(STR)
-#define PHP_HTTP_BUFFER_VAL_FREE(STR) PHP_HTTP_BUFFER_FREE_VAL,(STR)
-#define PHP_HTTP_BUFFER_NOT_FREE(STR) PHP_HTTP_BUFFER_FREE_NOT,(STR)
-
-#define PHP_HTTP_BUFFER_INIT_PREALLOC  0x01
-#define PHP_HTTP_BUFFER_INIT_PERSISTENT        0x02
-
-/* create a new php_http_buffer_t */
-#define php_http_buffer_new() php_http_buffer_init(NULL)
-#define php_http_buffer_init(b) php_http_buffer_init_ex(b, PHP_HTTP_BUFFER_DEFAULT_SIZE, 0)
-#define php_http_buffer_clone(from, to) php_http_buffer_init_ex((to), (from)->size, (from)->pmem ? PHP_HTTP_BUFFER_INIT_PERSISTENT:0)
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, int flags);
-
-/* create a php_http_buffer_t from a zval or c-string */
-#define php_http_buffer_from_zval(z) php_http_buffer_from_string(Z_STRVAL(z), Z_STRLEN(z))
-#define php_http_buffer_from_zval_ex(b, z) php_http_buffer_from_string_ex(b, Z_STRVAL(z), Z_STRLEN(z))
-#define php_http_buffer_from_string(s, l) php_http_buffer_from_string_ex(NULL, (s), (l))
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_buffer_t *buf, const char *string, size_t length);
-
-/* usually only called from within the internal functions */
-#define php_http_buffer_resize(b, s) php_http_buffer_resize_ex((b), (s), 0, 0)
-PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, size_t len, size_t override_size, int allow_error);
-
-PHP_HTTP_BUFFER_API char *php_http_buffer_account(php_http_buffer_t *buf, size_t to_account);
-
-/* shrink memory chunk to actually used size (+1) */
-PHP_HTTP_BUFFER_API size_t php_http_buffer_shrink(php_http_buffer_t *buf);
-
-/* append data to the php_http_buffer_t */
-#define php_http_buffer_appends(b, a) php_http_buffer_append((b), (a), sizeof(a)-1)
-#define php_http_buffer_appendl(b, a) php_http_buffer_append((b), (a), strlen(a))
-PHP_HTTP_BUFFER_API size_t php_http_buffer_append(php_http_buffer_t *buf, const char *append, size_t append_len);
-PHP_HTTP_BUFFER_API size_t php_http_buffer_appendf(php_http_buffer_t *buf, const char *format, ...) PHP_HTTP_BUFFER_ATTRIBUTE_FORMAT(printf, 2, 3);
-
-/* get a zero-terminated string */
-PHP_HTTP_BUFFER_API char *php_http_buffer_data(const php_http_buffer_t *buf, char **into, size_t *len);
-
-/* remove a substring */
-PHP_HTTP_BUFFER_API size_t php_http_buffer_cut(php_http_buffer_t *buf, size_t offset, size_t length);
-
-/* sets a trailing NUL byte */
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_fix(php_http_buffer_t *buf);
-
-/* reset php_http_buffer_t object */
-PHP_HTTP_BUFFER_API void php_http_buffer_reset(php_http_buffer_t *buf);
-
-/* free a php_http_buffer_t objects contents */
-PHP_HTTP_BUFFER_API void php_http_buffer_dtor(php_http_buffer_t *buf);
-
-/* free a php_http_buffer_t object completely */
-PHP_HTTP_BUFFER_API void php_http_buffer_free(php_http_buffer_t **buf);
-
-/* stores data in a php_http_buffer_t until it reaches chunk_size */
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunk_buffer(php_http_buffer_t **s, const char *data, size_t data_len, char **chunk, size_t chunk_size);
-
-typedef size_t (*php_http_buffer_pass_func_t)(void *opaque, char *, size_t TSRMLS_DC);
-
-PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *passin_arg, php_http_buffer_pass_func_t passon, void *passon_arg TSRMLS_DC);
-
-/* wrapper around php_http_buffer_chunk_buffer, which passes available chunks to passthru() */
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s, const char *data, size_t data_len, size_t chunk_size, php_http_buffer_pass_func_t passout, void *opaque TSRMLS_DC);
-
-/* write chunks directly into php_http_buffer_t buffer */
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_input(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *opaque TSRMLS_DC);
-
-
-#      ifdef PHP_HTTP_BUFFER_EXTENDED
-
-/* memcmp for php_http_buffer_t objects */
-PHP_HTTP_BUFFER_API int php_http_buffer_cmp(php_http_buffer_t *left, php_http_buffer_t *right);
-
-/* get a complete php_http_buffer_t duplicate */
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_copy(const php_http_buffer_t *from, php_http_buffer_t *to);
-
-/* merge several php_http_buffer_t objects
-   use like:
-
-       php_http_buffer_t *final = php_http_buffer_merge(3,
-               PHP_HTTP_BUFFER_NOT_FREE(&keep),
-               PHP_HTTP_BUFFER_ALL_FREE(middle_ptr),
-               PHP_HTTP_BUFFER_VAL_FREE(&local);
-*/
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge(unsigned argc, ...);
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_ex(php_http_buffer_t *buf, unsigned argc, ...);
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_va(php_http_buffer_t *buf, unsigned argc, va_list argv);
-
-/* insert data at a specific position of the php_http_buffer_t */
-#define php_http_buffer_inserts(b, i, o) php_http_buffer_insert((b), (i), sizeof(i)-1, (o))
-#define php_http_buffer_insertl(b, i, o) php_http_buffer_insert((b), (i), strlen(i), (o))
-PHP_HTTP_BUFFER_API size_t php_http_buffer_insert(php_http_buffer_t *buf, const char *insert, size_t insert_len, size_t offset);
-PHP_HTTP_BUFFER_API size_t php_http_buffer_insertf(php_http_buffer_t *buf, size_t offset, const char *format, ...) PHP_HTTP_BUFFER_ATTRIBUTE_FORMAT(printf, 3, 4);
-
-/* prepend data */
-#define php_http_buffer_prepends(b, p) php_http_buffer_prepend((b), (p), sizeof(p)-1)
-#define php_http_buffer_prependl(b, p) php_http_buffer_prepend((b), (p), strlen(p))
-PHP_HTTP_BUFFER_API size_t php_http_buffer_prepend(php_http_buffer_t *buf, const char *prepend, size_t prepend_len);
-PHP_HTTP_BUFFER_API size_t php_http_buffer_prependf(php_http_buffer_t *buf, const char *format, ...) PHP_HTTP_BUFFER_ATTRIBUTE_FORMAT(printf, 2, 3);
-
-/* get a part of the php_http_buffer_t */
-#define php_http_buffer_mid(b, o, l) php_http_buffer_sub((b), (o), (l))
-#define php_http_buffer_left(b, l) php_http_buffer_sub((b), 0, (l))
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_right(const php_http_buffer_t *buf, size_t length);
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_sub(const php_http_buffer_t *buf, size_t offset, size_t len);
-
-#      endif /* PHP_HTTP_BUFFER_EXTENDED */
-
-#endif /* PHP_HTTP_BUFFER_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/php_http_client.c b/php_http_client.c
deleted file mode 100644 (file)
index 160e8bb..0000000
+++ /dev/null
@@ -1,1284 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-#include "php_http_client.h"
-
-#include <ext/spl/spl_observer.h>
-
-/*
- * array of name => php_http_client_driver_t*
- */
-static HashTable php_http_client_drivers;
-
-ZEND_RESULT_CODE php_http_client_driver_add(php_http_client_driver_t *driver)
-{
-       return zend_hash_add(&php_http_client_drivers, driver->name_str, driver->name_len + 1, (void *) driver, sizeof(php_http_client_driver_t), NULL);
-}
-
-ZEND_RESULT_CODE php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver)
-{
-       php_http_client_driver_t *tmp;
-
-       if ((name_str && SUCCESS == zend_hash_find(&php_http_client_drivers, name_str, name_len + 1, (void *) &tmp))
-       ||      (SUCCESS == zend_hash_get_current_data(&php_http_client_drivers, (void *) &tmp))) {
-               *driver = *tmp;
-               return SUCCESS;
-       }
-       return FAILURE;
-}
-
-static int apply_driver_list(void *p, void *arg TSRMLS_DC)
-{
-       php_http_client_driver_t *d = p;
-       zval *zname;
-
-       MAKE_STD_ZVAL(zname);
-       ZVAL_STRINGL(zname, d->name_str, d->name_len, 1);
-
-       zend_hash_next_index_insert(arg, &zname, sizeof(zval *), NULL);
-       return ZEND_HASH_APPLY_KEEP;
-}
-
-void php_http_client_driver_list(HashTable *ht TSRMLS_DC)
-{
-       zend_hash_apply_with_argument(&php_http_client_drivers, apply_driver_list, ht TSRMLS_CC);
-}
-
-void php_http_client_options_set_subr(zval *this_ptr, char *key, size_t len, zval *opts, int overwrite TSRMLS_DC)
-{
-       if (overwrite || (opts && zend_hash_num_elements(Z_ARRVAL_P(opts)))) {
-               zend_class_entry *this_ce = Z_OBJCE_P(getThis());
-               zval *old_opts, *new_opts, **entry = NULL;
-
-               MAKE_STD_ZVAL(new_opts);
-               array_init(new_opts);
-               old_opts = zend_read_property(this_ce, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
-               if (Z_TYPE_P(old_opts) == IS_ARRAY) {
-                       array_copy(Z_ARRVAL_P(old_opts), Z_ARRVAL_P(new_opts));
-               }
-
-               if (overwrite) {
-                       if (opts && zend_hash_num_elements(Z_ARRVAL_P(opts))) {
-                               Z_ADDREF_P(opts);
-                               zend_symtable_update(Z_ARRVAL_P(new_opts), key, len, (void *) &opts, sizeof(zval *), NULL);
-                       } else {
-                               zend_symtable_del(Z_ARRVAL_P(new_opts), key, len);
-                       }
-               } else if (opts && zend_hash_num_elements(Z_ARRVAL_P(opts))) {
-                       if (SUCCESS == zend_symtable_find(Z_ARRVAL_P(new_opts), key, len, (void *) &entry)) {
-                               array_join(Z_ARRVAL_P(opts), Z_ARRVAL_PP(entry), 0, 0);
-                       } else {
-                               Z_ADDREF_P(opts);
-                               zend_symtable_update(Z_ARRVAL_P(new_opts), key, len, (void *) &opts, sizeof(zval *), NULL);
-                       }
-               }
-
-               zend_update_property(this_ce, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC);
-               zval_ptr_dtor(&new_opts);
-       }
-}
-
-void php_http_client_options_set(zval *this_ptr, zval *opts TSRMLS_DC)
-{
-       php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
-       HashPosition pos;
-       zval *new_opts;
-       zend_class_entry *this_ce = Z_OBJCE_P(getThis());
-       zend_bool is_client = instanceof_function(this_ce, php_http_client_class_entry TSRMLS_CC);
-
-       MAKE_STD_ZVAL(new_opts);
-       array_init(new_opts);
-
-       if (!opts || !zend_hash_num_elements(Z_ARRVAL_P(opts))) {
-               zend_update_property(this_ce, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC);
-               zval_ptr_dtor(&new_opts);
-       } else {
-               zval *old_opts, *add_opts, **opt;
-
-               MAKE_STD_ZVAL(add_opts);
-               array_init(add_opts);
-               /* some options need extra attention -- thus cannot use array_merge() directly */
-               FOREACH_KEYVAL(pos, opts, key, opt) {
-                       if (key.type == HASH_KEY_IS_STRING) {
-#define KEYMATCH(k, s) ((sizeof(s)==k.len) && !strcasecmp(k.str, s))
-                               if (Z_TYPE_PP(opt) == IS_ARRAY && (KEYMATCH(key, "ssl") || KEYMATCH(key, "cookies"))) {
-                                       php_http_client_options_set_subr(getThis(), key.str, key.len, *opt, 0 TSRMLS_CC);
-                               } else if (is_client && (KEYMATCH(key, "recordHistory") || KEYMATCH(key, "responseMessageClass"))) {
-                                       zend_update_property(this_ce, getThis(), key.str, key.len-1, *opt TSRMLS_CC);
-                               } else if (Z_TYPE_PP(opt) == IS_NULL) {
-                                       old_opts = zend_read_property(this_ce, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
-                                       if (Z_TYPE_P(old_opts) == IS_ARRAY) {
-                                               zend_symtable_del(Z_ARRVAL_P(old_opts), key.str, key.len);
-                                       }
-                               } else {
-                                       Z_ADDREF_P(*opt);
-                                       add_assoc_zval_ex(add_opts, key.str, key.len, *opt);
-                               }
-                       }
-               }
-
-               old_opts = zend_read_property(this_ce, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
-               if (Z_TYPE_P(old_opts) == IS_ARRAY) {
-                       array_copy(Z_ARRVAL_P(old_opts), Z_ARRVAL_P(new_opts));
-               }
-               array_join(Z_ARRVAL_P(add_opts), Z_ARRVAL_P(new_opts), 0, 0);
-               zend_update_property(this_ce, getThis(), ZEND_STRL("options"), new_opts TSRMLS_CC);
-               zval_ptr_dtor(&new_opts);
-               zval_ptr_dtor(&add_opts);
-       }
-}
-
-void php_http_client_options_get_subr(zval *this_ptr, char *key, size_t len, zval *return_value TSRMLS_DC)
-{
-       zend_class_entry *this_ce = Z_OBJCE_P(getThis());
-       zval **options, *opts = zend_read_property(this_ce, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
-
-       if ((Z_TYPE_P(opts) == IS_ARRAY) && (SUCCESS == zend_symtable_find(Z_ARRVAL_P(opts), key, len, (void *) &options))) {
-               RETVAL_ZVAL(*options, 1, 0);
-       }
-}
-
-static void queue_dtor(void *enqueued)
-{
-       php_http_client_enqueue_t *e = enqueued;
-
-       if (e->dtor) {
-               e->dtor(e);
-       }
-}
-
-php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC)
-{
-       php_http_client_t *free_h = NULL;
-
-       if (!h) {
-               free_h = h = emalloc(sizeof(*h));
-       }
-       memset(h, 0, sizeof(*h));
-
-       h->ops = ops;
-       if (rf) {
-               h->rf = rf;
-       } else if (ops->rsrc) {
-               h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL);
-       }
-       zend_llist_init(&h->requests, sizeof(php_http_client_enqueue_t), queue_dtor, 0);
-       zend_llist_init(&h->responses, sizeof(void *), NULL, 0);
-       TSRMLS_SET_CTX(h->ts);
-
-       if (h->ops->init) {
-               if (!(h = h->ops->init(h, init_arg))) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not initialize client");
-                       if (free_h) {
-                               efree(free_h);
-                       }
-               }
-       }
-
-       return h;
-}
-
-php_http_client_t *php_http_client_copy(php_http_client_t *from, php_http_client_t *to)
-{
-       if (from->ops->copy) {
-               return from->ops->copy(from, to);
-       }
-
-       return NULL;
-}
-
-void php_http_client_dtor(php_http_client_t *h)
-{
-       php_http_client_reset(h);
-
-       if (h->ops->dtor) {
-               h->ops->dtor(h);
-       }
-
-       php_resource_factory_free(&h->rf);
-}
-
-void php_http_client_free(php_http_client_t **h) {
-       if (*h) {
-               php_http_client_dtor(*h);
-               efree(*h);
-               *h = NULL;
-       }
-}
-
-ZEND_RESULT_CODE php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
-{
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-       if (h->ops->enqueue) {
-               if (php_http_client_enqueued(h, enqueue->request, NULL)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to enqueue request; request already in queue");
-                       return FAILURE;
-               }
-               return h->ops->enqueue(h, enqueue);
-       }
-
-       return FAILURE;
-}
-
-ZEND_RESULT_CODE php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request)
-{
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-       if (h->ops->dequeue) {
-               php_http_client_enqueue_t *enqueue = php_http_client_enqueued(h, request, NULL);
-
-               if (!enqueue) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to dequeue request; request not in queue");
-                       return FAILURE;
-               }
-               return h->ops->dequeue(h, enqueue);
-       }
-       return FAILURE;
-}
-
-php_http_client_enqueue_t *php_http_client_enqueued(php_http_client_t *h, void *compare_arg, php_http_client_enqueue_cmp_func_t compare_func)
-{
-       zend_llist_element *el = NULL;
-
-       if (compare_func) {
-               for (el = h->requests.head; el; el = el->next) {
-                       if (compare_func((php_http_client_enqueue_t *) el->data, compare_arg)) {
-                               break;
-                       }
-               }
-       } else {
-               for (el = h->requests.head; el; el = el->next) {
-                       if (((php_http_client_enqueue_t *) el->data)->request == compare_arg) {
-                               break;
-                       }
-               }
-       }
-       return el ? (php_http_client_enqueue_t *) el->data : NULL;
-}
-
-ZEND_RESULT_CODE php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout)
-{
-       if (h->ops->wait) {
-               return h->ops->wait(h, custom_timeout);
-       }
-
-       return FAILURE;
-}
-
-int php_http_client_once(php_http_client_t *h)
-{
-       if (h->ops->once) {
-               return h->ops->once(h);
-       }
-
-       return FAILURE;
-}
-
-ZEND_RESULT_CODE php_http_client_exec(php_http_client_t *h)
-{
-       if (h->ops->exec) {
-               return h->ops->exec(h);
-       }
-
-       return FAILURE;
-}
-
-void php_http_client_reset(php_http_client_t *h)
-{
-       if (h->ops->reset) {
-               h->ops->reset(h);
-       }
-
-       zend_llist_clean(&h->requests);
-       zend_llist_clean(&h->responses);
-}
-
-ZEND_RESULT_CODE php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
-{
-       if (h->ops->setopt) {
-               return h->ops->setopt(h, opt, arg);
-       }
-
-       return FAILURE;
-}
-
-ZEND_RESULT_CODE php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr)
-{
-       if (h->ops->getopt) {
-               return h->ops->getopt(h, opt, arg, res_ptr);
-       }
-       return FAILURE;
-}
-
-zend_class_entry *php_http_client_class_entry;
-static zend_object_handlers php_http_client_object_handlers;
-
-void php_http_client_object_free(void *object TSRMLS_DC)
-{
-       php_http_client_object_t *o = (php_http_client_object_t *) object;
-
-       php_http_client_free(&o->client);
-       php_http_object_method_dtor(&o->notify);
-       php_http_object_method_free(&o->update);
-       zend_object_std_dtor((zend_object *) o TSRMLS_CC);
-       efree(o);
-}
-
-zend_object_value php_http_client_object_new_ex(zend_class_entry *ce, php_http_client_t *client, php_http_client_object_t **ptr TSRMLS_DC)
-{
-       php_http_client_object_t *o;
-
-       o = ecalloc(1, sizeof(php_http_client_object_t));
-       zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-       object_properties_init((zend_object *) o, ce);
-
-       o->client = client;
-
-       if (ptr) {
-               *ptr = o;
-       }
-
-       o->zv.handle = zend_objects_store_put(o, NULL, php_http_client_object_free, NULL TSRMLS_CC);
-       o->zv.handlers = &php_http_client_object_handlers;
-
-       return o->zv;
-}
-
-zend_object_value php_http_client_object_new(zend_class_entry *ce TSRMLS_DC)
-{
-       return php_http_client_object_new_ex(ce, NULL, NULL TSRMLS_CC);
-}
-
-static void handle_history(zval *zclient, php_http_message_t *request, php_http_message_t *response TSRMLS_DC)
-{
-       zval *new_hist, *old_hist = zend_read_property(php_http_client_class_entry, zclient, ZEND_STRL("history"), 0 TSRMLS_CC);
-       php_http_message_t *zipped = php_http_message_zip(response, request);
-       zend_object_value ov = php_http_message_object_new_ex(php_http_message_class_entry, zipped, NULL TSRMLS_CC);
-
-       MAKE_STD_ZVAL(new_hist);
-       ZVAL_OBJVAL(new_hist, ov, 0);
-
-       if (Z_TYPE_P(old_hist) == IS_OBJECT) {
-               php_http_message_object_prepend(new_hist, old_hist, 1 TSRMLS_CC);
-       }
-
-       zend_update_property(php_http_client_class_entry, zclient, ZEND_STRL("history"), new_hist TSRMLS_CC);
-       zval_ptr_dtor(&new_hist);
-}
-
-static ZEND_RESULT_CODE handle_response(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_message_t **response)
-{
-       zend_bool dequeue = 0;
-       zval zclient;
-       php_http_message_t *msg;
-       php_http_client_progress_state_t *progress;
-       TSRMLS_FETCH_FROM_CTX(client->ts);
-
-       INIT_PZVAL(&zclient);
-       ZVAL_OBJVAL(&zclient, ((php_http_client_object_t*) arg)->zv, 0);
-
-       if ((msg = *response)) {
-               php_http_message_object_t *msg_obj;
-               zval *info, *zresponse, *zrequest;
-               HashTable *info_ht;
-
-               /* ensure the message is of type response (could be uninitialized in case of early error, like DNS) */
-               php_http_message_set_type(msg, PHP_HTTP_RESPONSE);
-
-               if (z_is_true(zend_read_property(php_http_client_class_entry, &zclient, ZEND_STRL("recordHistory"), 0 TSRMLS_CC))) {
-                       handle_history(&zclient, e->request, *response TSRMLS_CC);
-               }
-
-               /* hard detach, redirects etc. are in the history */
-               php_http_message_free(&msg->parent);
-               *response = NULL;
-
-               MAKE_STD_ZVAL(zresponse);
-               ZVAL_OBJVAL(zresponse, php_http_message_object_new_ex(php_http_client_response_class_entry, msg, &msg_obj TSRMLS_CC), 0);
-
-               MAKE_STD_ZVAL(zrequest);
-               ZVAL_OBJVAL(zrequest, ((php_http_message_object_t *) e->opaque)->zv, 1);
-
-               php_http_message_object_prepend(zresponse, zrequest, 1 TSRMLS_CC);
-
-               MAKE_STD_ZVAL(info);
-               object_init(info);
-               info_ht = HASH_OF(info);
-               php_http_client_getopt(client, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO, e->request, &info_ht);
-               zend_update_property(php_http_client_response_class_entry, zresponse, ZEND_STRL("transferInfo"), info TSRMLS_CC);
-               zval_ptr_dtor(&info);
-
-               zend_objects_store_add_ref_by_handle(msg_obj->zv.handle TSRMLS_CC);
-               zend_llist_add_element(&client->responses, &msg_obj);
-
-               if (e->closure.fci.size) {
-                       zval *retval = NULL;
-                       zend_error_handling zeh;
-
-                       zend_fcall_info_argn(&e->closure.fci TSRMLS_CC, 1, &zresponse);
-                       zend_replace_error_handling(EH_NORMAL, NULL, &zeh TSRMLS_CC);
-                       zend_fcall_info_call(&e->closure.fci, &e->closure.fcc, &retval, NULL TSRMLS_CC);
-                       zend_restore_error_handling(&zeh TSRMLS_CC);
-                       zend_fcall_info_argn(&e->closure.fci TSRMLS_CC, 0);
-
-                       if (retval) {
-                               if (Z_TYPE_P(retval) == IS_BOOL) {
-                                       dequeue = Z_BVAL_P(retval);
-                               }
-                               zval_ptr_dtor(&retval);
-                       }
-               }
-
-               zval_ptr_dtor(&zresponse);
-               zval_ptr_dtor(&zrequest);
-       }
-
-       if (SUCCESS == php_http_client_getopt(client, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO, e->request, &progress)) {
-               progress->info = "finished";
-               progress->finished = 1;
-               client->callback.progress.func(client->callback.progress.arg, client, e, progress);
-       }
-
-       if (dequeue) {
-               php_http_client_dequeue(client, e->request);
-       }
-
-       return SUCCESS;
-}
-
-static void handle_progress(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_client_progress_state_t *progress)
-{
-       zval *zrequest, *zprogress, *zclient, **args[2];
-       php_http_client_object_t *client_obj = arg;
-       zend_error_handling zeh;
-       TSRMLS_FETCH_FROM_CTX(client->ts);
-
-       MAKE_STD_ZVAL(zclient);
-       ZVAL_OBJVAL(zclient, client_obj->zv, 1);
-
-       MAKE_STD_ZVAL(zrequest);
-       ZVAL_OBJVAL(zrequest, ((php_http_message_object_t *) e->opaque)->zv, 1);
-       args[0] = &zrequest;
-
-       MAKE_STD_ZVAL(zprogress);
-       object_init(zprogress);
-       add_property_bool(zprogress, "started", progress->started);
-       add_property_bool(zprogress, "finished", progress->finished);
-       add_property_string(zprogress, "info", STR_PTR(progress->info), 1);
-       add_property_double(zprogress, "dltotal", progress->dl.total);
-       add_property_double(zprogress, "dlnow", progress->dl.now);
-       add_property_double(zprogress, "ultotal", progress->ul.total);
-       add_property_double(zprogress, "ulnow", progress->ul.now);
-       args[1] = &zprogress;
-
-       zend_replace_error_handling(EH_NORMAL, NULL, &zeh TSRMLS_CC);
-       php_http_object_method_call(&client_obj->notify, zclient, NULL, 2, args TSRMLS_CC);
-       zend_restore_error_handling(&zeh TSRMLS_CC);
-
-       zval_ptr_dtor(&zclient);
-       zval_ptr_dtor(&zrequest);
-       zval_ptr_dtor(&zprogress);
-}
-
-static void response_dtor(void *data)
-{
-       php_http_message_object_t *msg_obj = *(php_http_message_object_t **) data;
-       TSRMLS_FETCH_FROM_CTX(msg_obj->message->ts);
-
-       zend_objects_store_del_ref_by_handle_ex(msg_obj->zv.handle, msg_obj->zv.handlers TSRMLS_CC);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_construct, 0, 0, 0)
-       ZEND_ARG_INFO(0, driver)
-       ZEND_ARG_INFO(0, persistent_handle_id)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, __construct)
-{
-               char *driver_str = NULL, *persistent_handle_str = NULL;
-               int driver_len = 0, persistent_handle_len = 0;
-               php_http_client_driver_t driver;
-               php_resource_factory_t *rf = NULL;
-               php_http_client_object_t *obj;
-               zval *os;
-
-               php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ss", &driver_str, &driver_len, &persistent_handle_str, &persistent_handle_len), invalid_arg, return);
-
-               if (SUCCESS != php_http_client_driver_get(driver_str, driver_len, &driver)) {
-                       php_http_throw(unexpected_val, "Failed to locate \"%s\" client request handler", driver_str);
-                       return;
-               }
-
-               MAKE_STD_ZVAL(os);
-               object_init_ex(os, spl_ce_SplObjectStorage);
-               zend_update_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), os TSRMLS_CC);
-               zval_ptr_dtor(&os);
-
-               if (persistent_handle_len) {
-                       char *name_str;
-                       size_t name_len;
-                       php_persistent_handle_factory_t *pf;
-
-                       name_len = spprintf(&name_str, 0, "http\\Client\\%s", driver.name_str);
-                       php_http_pretty_key(name_str + sizeof("http\\Client"), driver.name_len, 1, 1);
-
-                       if ((pf = php_persistent_handle_concede(NULL , name_str, name_len, persistent_handle_str, persistent_handle_len, NULL, NULL TSRMLS_CC))) {
-                               rf = php_persistent_handle_resource_factory_init(NULL, pf);
-                       }
-
-                       efree(name_str);
-               }
-
-               obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-               php_http_expect(obj->client = php_http_client_init(NULL, driver.client_ops, rf, NULL TSRMLS_CC), runtime, return);
-
-               php_http_object_method_init(&obj->notify, getThis(), ZEND_STRL("notify") TSRMLS_CC);
-
-               obj->client->callback.response.func = handle_response;
-               obj->client->callback.response.arg = obj;
-               obj->client->callback.progress.func = handle_progress;
-               obj->client->callback.progress.arg = obj;
-
-               obj->client->responses.dtor = response_dtor;
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_reset, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, reset)
-{
-       php_http_client_object_t *obj;
-       php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       obj->iterator = 0;
-       php_http_client_reset(obj->client);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-static HashTable *combined_options(zval *client, zval *request TSRMLS_DC)
-{
-       HashTable *options;
-       int num_options = 0;
-       zval *z_roptions = NULL, *z_coptions = zend_read_property(php_http_client_class_entry, client, ZEND_STRL("options"), 0 TSRMLS_CC);
-
-       if (Z_TYPE_P(z_coptions) == IS_ARRAY) {
-               num_options = zend_hash_num_elements(Z_ARRVAL_P(z_coptions));
-       }
-       zend_call_method_with_0_params(&request, NULL, NULL, "getOptions", &z_roptions);
-       if (z_roptions && Z_TYPE_P(z_roptions) == IS_ARRAY) {
-               int num = zend_hash_num_elements(Z_ARRVAL_P(z_roptions));
-               if (num > num_options) {
-                       num_options = num;
-               }
-       }
-       ALLOC_HASHTABLE(options);
-       ZEND_INIT_SYMTABLE_EX(options, num_options, 0);
-       if (Z_TYPE_P(z_coptions) == IS_ARRAY) {
-               array_copy(Z_ARRVAL_P(z_coptions), options);
-       }
-       if (z_roptions) {
-               if (Z_TYPE_P(z_roptions) == IS_ARRAY) {
-                       array_join(Z_ARRVAL_P(z_roptions), options, 0, 0);
-               }
-               zval_ptr_dtor(&z_roptions);
-       }
-       return options;
-}
-
-static void msg_queue_dtor(php_http_client_enqueue_t *e)
-{
-       php_http_message_object_t *msg_obj = e->opaque;
-       TSRMLS_FETCH_FROM_CTX(msg_obj->message->ts);
-
-       zend_objects_store_del_ref_by_handle_ex(msg_obj->zv.handle, msg_obj->zv.handlers TSRMLS_CC);
-       zend_hash_destroy(e->options);
-       FREE_HASHTABLE(e->options);
-
-       if (e->closure.fci.size) {
-               zval_ptr_dtor(&e->closure.fci.function_name);
-               if (e->closure.fci.object_ptr) {
-                       zval_ptr_dtor(&e->closure.fci.object_ptr);
-               }
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enqueue, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 0)
-       ZEND_ARG_INFO(0, callable)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, enqueue)
-{
-       zval *request;
-       zend_fcall_info fci = empty_fcall_info;
-       zend_fcall_info_cache fcc = empty_fcall_info_cache;
-       php_http_client_object_t *obj;
-       php_http_message_object_t *msg_obj;
-       php_http_client_enqueue_t q;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|f", &request, php_http_client_request_class_entry, &fci, &fcc), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       msg_obj = zend_object_store_get_object(request TSRMLS_CC);
-
-       if (php_http_client_enqueued(obj->client, msg_obj->message, NULL)) {
-               php_http_throw(bad_method_call, "Failed to enqueue request; request already in queue", NULL);
-               return;
-       }
-
-       q.request = msg_obj->message;
-       q.options = combined_options(getThis(), request TSRMLS_CC);
-       q.dtor = msg_queue_dtor;
-       q.opaque = msg_obj;
-       q.closure.fci = fci;
-       q.closure.fcc = fcc;
-
-       if (fci.size) {
-               Z_ADDREF_P(fci.function_name);
-               if (fci.object_ptr) {
-                       Z_ADDREF_P(fci.object_ptr);
-               }
-       }
-
-       zend_objects_store_add_ref_by_handle(msg_obj->zv.handle TSRMLS_CC);
-
-       php_http_expect(SUCCESS == php_http_client_enqueue(obj->client, &q), runtime,
-                       msg_queue_dtor(&q);
-                       return;
-       );
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_dequeue, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, dequeue)
-{
-       zval *request;
-       php_http_client_object_t *obj;
-       php_http_message_object_t *msg_obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_client_request_class_entry), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       msg_obj = zend_object_store_get_object(request TSRMLS_CC);
-
-       if (!php_http_client_enqueued(obj->client, msg_obj->message, NULL)) {
-               php_http_throw(bad_method_call, "Failed to dequeue request; request not in queue", NULL);
-               return;
-       }
-
-       php_http_expect(SUCCESS == php_http_client_dequeue(obj->client, msg_obj->message), runtime, return);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_requeue, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 0)
-       ZEND_ARG_INFO(0, callable)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, requeue)
-{
-       zval *request;
-       zend_fcall_info fci = empty_fcall_info;
-       zend_fcall_info_cache fcc = empty_fcall_info_cache;
-       php_http_client_object_t *obj;
-       php_http_message_object_t *msg_obj;
-       php_http_client_enqueue_t q;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|f", &request, php_http_client_request_class_entry, &fci, &fcc), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       msg_obj = zend_object_store_get_object(request TSRMLS_CC);
-
-       if (php_http_client_enqueued(obj->client, msg_obj->message, NULL)) {
-               php_http_expect(SUCCESS == php_http_client_dequeue(obj->client, msg_obj->message), runtime, return);
-       }
-
-       q.request = msg_obj->message;
-       q.options = combined_options(getThis(), request TSRMLS_CC);
-       q.dtor = msg_queue_dtor;
-       q.opaque = msg_obj;
-       q.closure.fci = fci;
-       q.closure.fcc = fcc;
-
-       if (fci.size) {
-               Z_ADDREF_P(fci.function_name);
-               if (fci.object_ptr) {
-                       Z_ADDREF_P(fci.object_ptr);
-               }
-       }
-
-       zend_objects_store_add_ref_by_handle(msg_obj->zv.handle TSRMLS_CC);
-
-       php_http_expect(SUCCESS == php_http_client_enqueue(obj->client, &q), runtime,
-                       msg_queue_dtor(&q);
-                       return;
-       );
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_count, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, count)
-{
-       long count_mode = -1;
-
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &count_mode)) {
-               php_http_client_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-               RETVAL_LONG(zend_llist_count(&obj->client->requests));
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getResponse, 0, 0, 0)
-       ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getResponse)
-{
-       zval *zrequest = NULL;
-       php_http_client_object_t *obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O", &zrequest, php_http_client_request_class_entry), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       if (zrequest) {
-               /* lookup the response with the request */
-               zend_llist_element *el = NULL;
-               php_http_message_object_t *req_obj = zend_object_store_get_object(zrequest TSRMLS_CC);
-
-               for (el = obj->client->responses.head; el; el = el->next) {
-                       php_http_message_object_t *response_obj = *(php_http_message_object_t **) el->data;
-
-                       if (response_obj->message->parent == req_obj->message) {
-                               RETURN_OBJVAL(response_obj->zv, 1);
-                       }
-               }
-
-               /* not found for the request! */
-               php_http_throw(unexpected_val, "Could not find response for the request", NULL);
-               return;
-       }
-
-       /* pop off the last response */
-       if (obj->client->responses.tail) {
-               php_http_message_object_t *response_obj = *(php_http_message_object_t **) obj->client->responses.tail->data;
-
-               /* pop off and go */
-               if (response_obj) {
-                       RETVAL_OBJVAL(response_obj->zv, 1);
-                       zend_llist_remove_tail(&obj->client->responses);
-               }
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getHistory, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getHistory)
-{
-       zval *zhistory;
-
-       php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
-
-       zhistory = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("history"), 0 TSRMLS_CC);
-       RETVAL_ZVAL(zhistory, 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_send, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, send)
-{
-       php_http_client_object_t *obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       php_http_expect(SUCCESS == php_http_client_exec(obj->client), runtime, return);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_once, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, once)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_client_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-               RETURN_BOOL(0 < php_http_client_once(obj->client));
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_wait, 0, 0, 0)
-       ZEND_ARG_INFO(0, timeout)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, wait)
-{
-       double timeout = 0;
-
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", &timeout)) {
-               struct timeval timeout_val;
-               php_http_client_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-               timeout_val.tv_sec = (time_t) timeout;
-               timeout_val.tv_usec = PHP_HTTP_USEC(timeout) % PHP_HTTP_MCROSEC;
-
-               RETURN_BOOL(SUCCESS == php_http_client_wait(obj->client, timeout > 0 ? &timeout_val : NULL));
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_configure, 0, 0, 1)
-       ZEND_ARG_ARRAY_INFO(0, settings, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, configure)
-{
-       HashTable *settings = NULL;
-       php_http_client_object_t *obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|H!", &settings), invalid_arg, return);
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       php_http_expect(SUCCESS == php_http_client_setopt(obj->client, PHP_HTTP_CLIENT_OPT_CONFIGURATION, settings), unexpected_val, return);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enablePipelining, 0, 0, 0)
-       ZEND_ARG_INFO(0, enable)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, enablePipelining)
-{
-       zend_bool enable = 1;
-       php_http_client_object_t *obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &enable), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       php_http_expect(SUCCESS == php_http_client_setopt(obj->client, PHP_HTTP_CLIENT_OPT_ENABLE_PIPELINING, &enable), unexpected_val, return);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_enableEvents, 0, 0, 0)
-       ZEND_ARG_INFO(0, enable)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, enableEvents)
-{
-       zend_bool enable = 1;
-       php_http_client_object_t *obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &enable), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       php_http_expect(SUCCESS == php_http_client_setopt(obj->client, PHP_HTTP_CLIENT_OPT_USE_EVENTS, &enable), unexpected_val, return);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-struct notify_arg {
-       php_http_object_method_t *cb;
-       zval **args[3];
-       int argc;
-};
-
-static int notify(zend_object_iterator *iter, void *puser TSRMLS_DC)
-{
-       zval **observer = NULL;
-       struct notify_arg *arg = puser;
-
-       iter->funcs->get_current_data(iter, &observer TSRMLS_CC);
-       if (observer) {
-               return php_http_object_method_call(arg->cb, *observer, NULL, arg->argc, arg->args TSRMLS_CC);
-       }
-       return FAILURE;
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_notify, 0, 0, 0)
-       ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, notify)
-{
-       zval *request = NULL, *zprogress = NULL, *observers;
-       php_http_client_object_t *client_obj;
-       struct notify_arg arg = {NULL};
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O!o!", &request, php_http_client_request_class_entry, &zprogress), invalid_arg, return);
-
-       client_obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC);
-
-       if (Z_TYPE_P(observers) != IS_OBJECT) {
-               php_http_throw(unexpected_val, "Observer storage is corrupted", NULL);
-               return;
-       }
-
-       if (client_obj->update) {
-               arg.cb = client_obj->update;
-
-               Z_ADDREF_P(getThis());
-               arg.args[0] = &getThis();
-               arg.argc = 1;
-
-               if (request) {
-                       Z_ADDREF_P(request);
-                       arg.args[1] = &request;
-                       arg.argc += 1;
-               }
-
-               if (zprogress) {
-                       Z_ADDREF_P(zprogress);
-                       arg.args[2] = &zprogress;
-                       arg.argc += 1;
-               }
-
-               spl_iterator_apply(observers, notify, &arg TSRMLS_CC);
-
-               zval_ptr_dtor(&getThis());
-               if (request) {
-                       zval_ptr_dtor(&request);
-               }
-               if (zprogress) {
-                       zval_ptr_dtor(&zprogress);
-               }
-       }
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_attach, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, observer, SplObserver, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, attach)
-{
-       zval *observers, *observer, *retval = NULL;
-       php_http_client_object_t *client_obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &observer, spl_ce_SplObserver), invalid_arg, return);
-
-       client_obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC);
-
-       if (Z_TYPE_P(observers) != IS_OBJECT) {
-               php_http_throw(unexpected_val, "Observer storage is corrupted", NULL);
-               return;
-       }
-
-       if (!client_obj->update) {
-               client_obj->update = php_http_object_method_init(NULL, observer, ZEND_STRL("update") TSRMLS_CC);
-       }
-
-       zend_call_method_with_1_params(&observers, NULL, NULL, "attach", &retval, observer);
-       if (retval) {
-               zval_ptr_dtor(&retval);
-       }
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_detach, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, observer, SplObserver, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, detach)
-{
-       zval *observers, *observer, *retval = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &observer, spl_ce_SplObserver), invalid_arg, return);
-
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC);
-
-       if (Z_TYPE_P(observers) != IS_OBJECT) {
-               php_http_throw(unexpected_val, "Observer storage is corrupted", NULL);
-               return;
-       }
-
-       zend_call_method_with_1_params(&observers, NULL, NULL, "detach", &retval, observer);
-       if (retval) {
-               zval_ptr_dtor(&retval);
-       }
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getObservers, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getObservers)
-{
-       zval *observers;
-
-       php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
-
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0 TSRMLS_CC);
-
-       if (Z_TYPE_P(observers) != IS_OBJECT) {
-               php_http_throw(unexpected_val, "Observer storage is corrupted", NULL);
-               return;
-       }
-
-       RETVAL_ZVAL(observers, 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getProgressInfo, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getProgressInfo)
-{
-       zval *request;
-       php_http_client_object_t *obj;
-       php_http_message_object_t *req_obj;
-       php_http_client_progress_state_t *progress;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_client_request_class_entry), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       req_obj = zend_object_store_get_object(request TSRMLS_CC);
-
-       php_http_expect(SUCCESS == php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO, req_obj->message, &progress), unexpected_val, return);
-
-       object_init(return_value);
-       add_property_bool(return_value, "started", progress->started);
-       add_property_bool(return_value, "finished", progress->finished);
-       add_property_string(return_value, "info", STR_PTR(progress->info), 1);
-       add_property_double(return_value, "dltotal", progress->dl.total);
-       add_property_double(return_value, "dlnow", progress->dl.now);
-       add_property_double(return_value, "ultotal", progress->ul.total);
-       add_property_double(return_value, "ulnow", progress->ul.now);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getTransferInfo, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getTransferInfo)
-{
-       zval *request;
-       HashTable *info;
-       php_http_client_object_t *obj;
-       php_http_message_object_t *req_obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, php_http_client_request_class_entry), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       req_obj = zend_object_store_get_object(request TSRMLS_CC);
-
-       object_init(return_value);
-       info = HASH_OF(return_value);
-       php_http_expect(SUCCESS == php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO, req_obj->message, &info), unexpected_val, return);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setOptions, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, options, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, setOptions)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set(getThis(), opts TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getOptions, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getOptions)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               zval *options = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
-               RETVAL_ZVAL(options, 1, 0);
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setSslOptions, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, ssl_option, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, setSslOptions)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts, 1 TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addSslOptions, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, ssl_options, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, addSslOptions)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts, 0 TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getSslOptions, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getSslOptions)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_client_options_get_subr(getThis(), ZEND_STRS("ssl"), return_value TSRMLS_CC);
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_setCookies, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, cookies, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, setCookies)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set_subr(getThis(), ZEND_STRS("cookies"), opts, 1 TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_addCookies, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, cookies, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, addCookies)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set_subr(getThis(), ZEND_STRS("cookies"), opts, 0 TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getCookies, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getCookies)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_client_options_get_subr(getThis(), ZEND_STRS("cookies"), return_value TSRMLS_CC);
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableDrivers, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getAvailableDrivers) {
-       if (SUCCESS == zend_parse_parameters_none()) {
-               array_init(return_value);
-               php_http_client_driver_list(Z_ARRVAL_P(return_value) TSRMLS_CC);
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableOptions, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getAvailableOptions)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_client_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-               array_init(return_value);
-               php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_AVAILABLE_OPTIONS, NULL, &Z_ARRVAL_P(return_value));
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_getAvailableConfiguration, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClient, getAvailableConfiguration)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_client_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-               array_init(return_value);
-               php_http_client_getopt(obj->client, PHP_HTTP_CLIENT_OPT_AVAILABLE_CONFIGURATION, NULL, &Z_ARRVAL_P(return_value));
-       }
-}
-
-static zend_function_entry php_http_client_methods[] = {
-       PHP_ME(HttpClient, __construct,          ai_HttpClient_construct,            ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
-       PHP_ME(HttpClient, reset,                ai_HttpClient_reset,                ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, enqueue,              ai_HttpClient_enqueue,              ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, dequeue,              ai_HttpClient_dequeue,              ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, requeue,              ai_HttpClient_requeue,              ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, count,                ai_HttpClient_count,                ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, send,                 ai_HttpClient_send,                 ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, once,                 ai_HttpClient_once,                 ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, wait,                 ai_HttpClient_wait,                 ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getResponse,          ai_HttpClient_getResponse,          ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getHistory,           ai_HttpClient_getHistory,           ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, configure,            ai_HttpClient_configure,            ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, enablePipelining,     ai_HttpClient_enablePipelining,     ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
-       PHP_ME(HttpClient, enableEvents,         ai_HttpClient_enableEvents,         ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
-       PHP_ME(HttpClient, notify,               ai_HttpClient_notify,               ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, attach,               ai_HttpClient_attach,               ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, detach,               ai_HttpClient_detach,               ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getObservers,         ai_HttpClient_getObservers,         ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getProgressInfo,      ai_HttpClient_getProgressInfo,      ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getTransferInfo,      ai_HttpClient_getTransferInfo,      ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, setOptions,           ai_HttpClient_setOptions,           ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getOptions,           ai_HttpClient_getOptions,           ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, setSslOptions,        ai_HttpClient_setSslOptions,        ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, addSslOptions,        ai_HttpClient_addSslOptions,        ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getSslOptions,        ai_HttpClient_getSslOptions,        ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, setCookies,           ai_HttpClient_setCookies,           ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, addCookies,           ai_HttpClient_addCookies,           ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getCookies,           ai_HttpClient_getCookies,           ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getAvailableDrivers,  ai_HttpClient_getAvailableDrivers,  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME(HttpClient, getAvailableOptions,  ai_HttpClient_getAvailableOptions,  ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClient, getAvailableConfiguration, ai_HttpClient_getAvailableConfiguration, ZEND_ACC_PUBLIC)
-       EMPTY_FUNCTION_ENTRY
-};
-
-PHP_MINIT_FUNCTION(http_client)
-{
-       zend_class_entry ce = {0};
-
-       INIT_NS_CLASS_ENTRY(ce, "http", "Client", php_http_client_methods);
-       php_http_client_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
-       php_http_client_class_entry->create_object = php_http_client_object_new;
-       zend_class_implements(php_http_client_class_entry TSRMLS_CC, 2, spl_ce_SplSubject, spl_ce_Countable);
-       memcpy(&php_http_client_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-       php_http_client_object_handlers.clone_obj = NULL;
-       zend_declare_property_null(php_http_client_class_entry, ZEND_STRL("observers"), ZEND_ACC_PRIVATE TSRMLS_CC);
-       zend_declare_property_null(php_http_client_class_entry, ZEND_STRL("options"), ZEND_ACC_PROTECTED TSRMLS_CC);
-       zend_declare_property_null(php_http_client_class_entry, ZEND_STRL("history"), ZEND_ACC_PROTECTED TSRMLS_CC);
-       zend_declare_property_bool(php_http_client_class_entry, ZEND_STRL("recordHistory"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
-
-       zend_hash_init(&php_http_client_drivers, 2, NULL, NULL, 1);
-
-       return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(http_client)
-{
-       zend_hash_destroy(&php_http_client_drivers);
-       return SUCCESS;
-}
-
-/*
- * 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
- */
diff --git a/php_http_client.h b/php_http_client.h
deleted file mode 100644 (file)
index f4a5b59..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_CLIENT_H
-#define PHP_HTTP_CLIENT_H
-
-typedef enum php_http_client_setopt_opt {
-       PHP_HTTP_CLIENT_OPT_ENABLE_PIPELINING,
-       PHP_HTTP_CLIENT_OPT_USE_EVENTS,
-       PHP_HTTP_CLIENT_OPT_CONFIGURATION,
-} php_http_client_setopt_opt_t;
-
-typedef enum php_http_client_getopt_opt {
-       PHP_HTTP_CLIENT_OPT_PROGRESS_INFO,              /* php_http_client_enqueue_t*, php_http_client_progress_state_t** */
-       PHP_HTTP_CLIENT_OPT_TRANSFER_INFO,              /* php_http_client_enqueue_t*, HashTable* */
-       PHP_HTTP_CLIENT_OPT_AVAILABLE_OPTIONS,          /* NULL, HashTable* */
-       PHP_HTTP_CLIENT_OPT_AVAILABLE_CONFIGURATION,/* NULL, HashTable */
-} php_http_client_getopt_opt_t;
-
-typedef struct php_http_client_enqueue {
-       php_http_message_t *request; /* unique */
-       HashTable *options;
-       void (*dtor)(struct php_http_client_enqueue *);
-       void *opaque;
-       struct {
-               zend_fcall_info fci;
-               zend_fcall_info_cache fcc;
-       } closure;
-} php_http_client_enqueue_t;
-
-typedef struct php_http_client *(*php_http_client_init_func_t)(struct php_http_client *p, void *init_arg);
-typedef struct php_http_client *(*php_http_client_copy_func_t)(struct php_http_client *from, struct php_http_client *to);
-typedef void (*php_http_client_dtor_func_t)(struct php_http_client *p);
-typedef void (*php_http_client_reset_func_t)(struct php_http_client *p);
-typedef ZEND_RESULT_CODE (*php_http_client_exec_func_t)(struct php_http_client *p);
-typedef int (*php_http_client_once_func_t)(struct php_http_client *p);
-typedef ZEND_RESULT_CODE (*php_http_client_wait_func_t)(struct php_http_client *p, struct timeval *custom_timeout);
-typedef ZEND_RESULT_CODE (*php_http_client_enqueue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
-typedef ZEND_RESULT_CODE (*php_http_client_dequeue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
-typedef ZEND_RESULT_CODE (*php_http_client_setopt_func_t)(struct php_http_client *p, php_http_client_setopt_opt_t opt, void *arg);
-typedef ZEND_RESULT_CODE (*php_http_client_getopt_func_t)(struct php_http_client *h, php_http_client_getopt_opt_t opt, void *arg, void **res);
-
-typedef struct php_http_client_ops {
-       php_resource_factory_ops_t *rsrc;
-       php_http_client_init_func_t init;
-       php_http_client_copy_func_t copy;
-       php_http_client_dtor_func_t dtor;
-       php_http_client_reset_func_t reset;
-       php_http_client_exec_func_t exec;
-       php_http_client_wait_func_t wait;
-       php_http_client_once_func_t once;
-       php_http_client_enqueue_func_t enqueue;
-       php_http_client_dequeue_func_t dequeue;
-       php_http_client_setopt_func_t setopt;
-       php_http_client_getopt_func_t getopt;
-} php_http_client_ops_t;
-
-typedef struct php_http_client_driver {
-       const char *name_str;
-       size_t name_len;
-       php_http_client_ops_t *client_ops;
-} php_http_client_driver_t;
-
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_driver_add(php_http_client_driver_t *driver);
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver);
-
-typedef struct php_http_client_progress_state {
-       struct {
-               double now;
-               double total;
-       } ul;
-       struct {
-               double now;
-               double total;
-       } dl;
-       const char *info;
-       unsigned started:1;
-       unsigned finished:1;
-} php_http_client_progress_state_t;
-
-typedef ZEND_RESULT_CODE (*php_http_client_response_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_message_t **response);
-typedef void (*php_http_client_progress_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_client_progress_state_t *state);
-
-typedef struct php_http_client {
-       void *ctx;
-       php_resource_factory_t *rf;
-       php_http_client_ops_t *ops;
-
-       struct {
-               struct {
-                       php_http_client_response_callback_t func;
-                       void *arg;
-               } response;
-               struct {
-                       php_http_client_progress_callback_t func;
-                       void *arg;
-               } progress;
-       } callback;
-
-       zend_llist requests;
-       zend_llist responses;
-
-#ifdef ZTS
-       void ***ts;
-#endif
-} php_http_client_t;
-
-PHP_HTTP_API zend_class_entry *php_http_client_class_entry;
-
-typedef struct php_http_client_object {
-       zend_object zo;
-       zend_object_value zv;
-       php_http_client_t *client;
-       long iterator;
-       php_http_object_method_t *update;
-       php_http_object_method_t notify;
-} php_http_client_object_t;
-
-PHP_HTTP_API php_http_client_t *php_http_client_init(php_http_client_t *h, php_http_client_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC);
-PHP_HTTP_API php_http_client_t *php_http_client_copy(php_http_client_t *from, php_http_client_t *to);
-PHP_HTTP_API void php_http_client_dtor(php_http_client_t *h);
-PHP_HTTP_API void php_http_client_free(php_http_client_t **h);
-
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue);
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request);
-
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout);
-PHP_HTTP_API int php_http_client_once(php_http_client_t *h);
-
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_exec(php_http_client_t *h);
-PHP_HTTP_API void php_http_client_reset(php_http_client_t *h);
-
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg);
-PHP_HTTP_API ZEND_RESULT_CODE php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr);
-
-typedef int (*php_http_client_enqueue_cmp_func_t)(php_http_client_enqueue_t *cmp, void *arg);
-/* compare with request message pointer if compare_func is NULL */
-PHP_HTTP_API php_http_client_enqueue_t *php_http_client_enqueued(php_http_client_t *h, void *compare_arg, php_http_client_enqueue_cmp_func_t compare_func);
-
-PHP_MINIT_FUNCTION(http_client);
-PHP_MSHUTDOWN_FUNCTION(http_client);
-
-#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
- */
diff --git a/php_http_client_curl.c b/php_http_client_curl.c
deleted file mode 100644 (file)
index fed92fc..0000000
+++ /dev/null
@@ -1,2599 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-#include "php_http_client.h"
-
-#if PHP_HTTP_HAVE_CURL
-
-#if PHP_HTTP_HAVE_EVENT
-#      if !PHP_HTTP_HAVE_EVENT2 && /* just be really sure */ !(LIBEVENT_VERSION_NUMBER >= 0x02000000)
-#              include <event.h>
-#              define event_base_new event_init
-#              define event_assign(e, b, s, a, cb, d) do {\
-                       event_set(e, s, a, cb, d); \
-                       event_base_set(b, e); \
-               } while(0)
-#      else
-#              if PHP_HTTP_HAVE_EVENT2
-#                      include <event2/event.h>
-#                      include <event2/event_struct.h>
-#              else
-#                      error "libevent presence is unknown"
-#              endif
-#      endif
-#      ifndef DBG_EVENTS
-#              define DBG_EVENTS 0
-#      endif
-#endif
-
-#ifdef PHP_HTTP_HAVE_OPENSSL
-#      include <openssl/ssl.h>
-#endif
-#ifdef PHP_HTTP_HAVE_GNUTLS
-#      include <gnutls.h>
-#endif
-
-typedef struct php_http_client_curl {
-       CURLM *handle;
-
-       int unfinished;  /* int because of curl_multi_perform() */
-
-#if PHP_HTTP_HAVE_EVENT
-       struct event_base *evbase;
-       struct event *timeout;
-       unsigned useevents:1;
-#endif
-} php_http_client_curl_t;
-
-typedef struct php_http_client_curl_handler {
-       CURL *handle;
-       php_resource_factory_t *rf;
-       php_http_client_t *client;
-       php_http_client_progress_state_t progress;
-       php_http_client_enqueue_t queue;
-
-       struct {
-               php_http_buffer_t headers;
-               php_http_message_body_t *body;
-       } response;
-
-       struct {
-               HashTable cache;
-
-               struct curl_slist *proxyheaders;
-               struct curl_slist *headers;
-               struct curl_slist *resolve;
-               php_http_buffer_t cookies;
-               php_http_buffer_t ranges;
-
-               long redirects;
-               unsigned range_request:1;
-               unsigned encode_cookies:1;
-
-               struct {
-                       uint count;
-                       double delay;
-               } retry;
-
-       } options;
-
-} php_http_client_curl_handler_t;
-
-typedef struct php_http_curle_storage {
-       char *url;
-       char *cookiestore;
-       CURLcode errorcode;
-       char errorbuffer[0x100];
-} php_http_curle_storage_t;
-
-static inline php_http_curle_storage_t *php_http_curle_get_storage(CURL *ch) {
-       php_http_curle_storage_t *st = NULL;
-
-       curl_easy_getinfo(ch, CURLINFO_PRIVATE, &st);
-
-       if (!st) {
-               st = pecalloc(1, sizeof(*st), 1);
-               curl_easy_setopt(ch, CURLOPT_PRIVATE, st);
-               curl_easy_setopt(ch, CURLOPT_ERRORBUFFER, st->errorbuffer);
-       }
-
-       return st;
-}
-
-static void *php_http_curle_ctor(void *opaque, void *init_arg TSRMLS_DC)
-{
-       void *ch;
-
-       if ((ch = curl_easy_init())) {
-               php_http_curle_get_storage(ch);
-               return ch;
-       }
-       return NULL;
-}
-
-static void *php_http_curle_copy(void *opaque, void *handle TSRMLS_DC)
-{
-       void *ch;
-
-       if ((ch = curl_easy_duphandle(handle))) {
-               curl_easy_reset(ch);
-               php_http_curle_get_storage(ch);
-               return ch;
-       }
-       return NULL;
-}
-
-static void php_http_curle_dtor(void *opaque, void *handle TSRMLS_DC)
-{
-       php_http_curle_storage_t *st = php_http_curle_get_storage(handle);
-
-       curl_easy_cleanup(handle);
-
-       if (st) {
-               if (st->url) {
-                       pefree(st->url, 1);
-               }
-               if (st->cookiestore) {
-                       pefree(st->cookiestore, 1);
-               }
-               pefree(st, 1);
-       }
-}
-
-static php_resource_factory_ops_t php_http_curle_resource_factory_ops = {
-       php_http_curle_ctor,
-       php_http_curle_copy,
-       php_http_curle_dtor
-};
-
-static void *php_http_curlm_ctor(void *opaque, void *init_arg TSRMLS_DC)
-{
-       return curl_multi_init();
-}
-
-static void php_http_curlm_dtor(void *opaque, void *handle TSRMLS_DC)
-{
-       curl_multi_cleanup(handle);
-}
-
-static php_resource_factory_ops_t php_http_curlm_resource_factory_ops = {
-       php_http_curlm_ctor,
-       NULL,
-       php_http_curlm_dtor
-};
-
-/* curl callbacks */
-
-static size_t php_http_curle_read_callback(void *data, size_t len, size_t n, void *ctx)
-{
-       php_http_message_body_t *body = ctx;
-
-       if (body && body->stream_id) {
-               php_stream *s = php_http_message_body_stream(body);
-
-               if (s) {
-                       TSRMLS_FETCH_FROM_CTX(body->ts);
-                       return php_stream_read(s, data, len * n);
-               } else abort();
-       }
-       return 0;
-}
-
-#if PHP_HTTP_CURL_VERSION(7,32,0)
-static int php_http_curle_xferinfo_callback(void *ctx, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
-#else
-static int php_http_curle_progress_callback(void *ctx, double dltotal, double dlnow, double ultotal, double ulnow)
-#endif
-{
-       php_http_client_curl_handler_t *h = ctx;
-       zend_bool update = 0;
-
-       if (h->progress.dl.total != dltotal
-       ||      h->progress.dl.now != dlnow
-       ||      h->progress.ul.total != ultotal
-       ||      h->progress.ul.now != ulnow
-       ) {
-               update = 1;
-
-               h->progress.dl.total = dltotal;
-               h->progress.dl.now = dlnow;
-               h->progress.ul.total = ultotal;
-               h->progress.ul.now = ulnow;
-       }
-
-       if (update && h->client->callback.progress.func) {
-               h->client->callback.progress.func(h->client->callback.progress.arg, h->client, &h->queue, &h->progress);
-       }
-
-       return 0;
-}
-
-static int php_http_curle_seek_callback(void *userdata, curl_off_t offset, int origin)
-{
-       php_http_message_body_t *body = userdata;
-       TSRMLS_FETCH_FROM_CTX(body->ts);
-
-       if (!body) {
-               return 1;
-       }
-       if (0 == php_stream_seek(php_http_message_body_stream(body), offset, origin)) {
-               return 0;
-       }
-       return 2;
-}
-
-static int php_http_curle_raw_callback(CURL *ch, curl_infotype type, char *data, size_t length, void *ctx)
-{
-       php_http_client_curl_handler_t *h = ctx;
-
-       /* catch progress */
-       switch (type) {
-               case CURLINFO_TEXT:
-                       if (data[0] == '-') {
-                       } else if (php_memnstr(data, ZEND_STRL("Adding handle:"), data + length)) {
-                               h->progress.info = "setup";
-                       } else if (php_memnstr(data, ZEND_STRL("addHandle"), data + length)) {
-                               h->progress.info = "setup";
-                       } else if (php_memnstr(data, ZEND_STRL("About to connect"), data + length)) {
-                               h->progress.info = "resolve";
-                       } else if (php_memnstr(data, ZEND_STRL("Trying"), data + length)) {
-                               h->progress.info = "connect";
-                       } else if (php_memnstr(data, ZEND_STRL("Found bundle for host"), data + length)) {
-                               h->progress.info = "connect";
-                       } else if (php_memnstr(data, ZEND_STRL("Connected"), data + length)) {
-                               h->progress.info = "connected";
-                       } else if (php_memnstr(data, ZEND_STRL("Re-using existing connection!"), data + length)) {
-                               h->progress.info = "connected";
-                       } else if (php_memnstr(data, ZEND_STRL("blacklisted"), data + length)) {
-                               h->progress.info = "blacklist check";
-                       } else if (php_memnstr(data, ZEND_STRL("SSL"), data + length)) {
-                               h->progress.info = "ssl negotiation";
-                       } else if (php_memnstr(data, ZEND_STRL("upload"), data + length)) {
-                               h->progress.info = "uploaded";
-                       } else if (php_memnstr(data, ZEND_STRL("left intact"), data + length)) {
-                               h->progress.info = "not disconnected";
-                       } else if (php_memnstr(data, ZEND_STRL("closed"), data + length)) {
-                               h->progress.info = "disconnected";
-                       } else if (php_memnstr(data, ZEND_STRL("Issue another request"), data + length)) {
-                               h->progress.info = "redirect";
-                       } else if (php_memnstr(data, ZEND_STRL("Operation timed out"), data + length)) {
-                               h->progress.info = "timeout";
-                       } else {
-#if 0
-                               h->progress.info = data;
-                               data[length - 1] = '\0';
-#endif
-                       }
-                       if (h->client->callback.progress.func) {
-                               h->client->callback.progress.func(h->client->callback.progress.arg, h->client, &h->queue, &h->progress);
-                       }
-                       break;
-               case CURLINFO_HEADER_OUT:
-               case CURLINFO_DATA_OUT:
-               case CURLINFO_SSL_DATA_OUT:
-                       h->progress.info = "send";
-                       break;
-               case CURLINFO_HEADER_IN:
-               case CURLINFO_DATA_IN:
-               case CURLINFO_SSL_DATA_IN:
-                       h->progress.info = "receive";
-                       break;
-               default:
-                       break;
-       }
-
-#if 0
-       /* debug */
-       _dpf(type, data, length);
-#endif
-
-       return 0;
-}
-
-static int php_http_curle_header_callback(char *data, size_t n, size_t l, void *arg)
-{
-       php_http_client_curl_handler_t *h = arg;
-
-       return php_http_buffer_append(&h->response.headers, data, n * l);
-}
-
-static int php_http_curle_body_callback(char *data, size_t n, size_t l, void *arg)
-{
-       php_http_client_curl_handler_t *h = arg;
-
-       return php_http_message_body_append(h->response.body, data, n*l);
-}
-
-static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
-{
-       char *c;
-       long l;
-       double d;
-       struct curl_slist *s, *p;
-       zval *subarray, array;
-       INIT_PZVAL_ARRAY(&array, info);
-
-       /* BEGIN::CURLINFO */
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_EFFECTIVE_URL, &c)) {
-               add_assoc_string_ex(&array, "effective_url", sizeof("effective_url"), c ? c : "", 1);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &l)) {
-               add_assoc_long_ex(&array, "response_code", sizeof("response_code"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_TOTAL_TIME, &d)) {
-               add_assoc_double_ex(&array, "total_time", sizeof("total_time"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_NAMELOOKUP_TIME, &d)) {
-               add_assoc_double_ex(&array, "namelookup_time", sizeof("namelookup_time"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONNECT_TIME, &d)) {
-               add_assoc_double_ex(&array, "connect_time", sizeof("connect_time"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRETRANSFER_TIME, &d)) {
-               add_assoc_double_ex(&array, "pretransfer_time", sizeof("pretransfer_time"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SIZE_UPLOAD, &d)) {
-               add_assoc_double_ex(&array, "size_upload", sizeof("size_upload"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SIZE_DOWNLOAD, &d)) {
-               add_assoc_double_ex(&array, "size_download", sizeof("size_download"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SPEED_DOWNLOAD, &d)) {
-               add_assoc_double_ex(&array, "speed_download", sizeof("speed_download"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SPEED_UPLOAD, &d)) {
-               add_assoc_double_ex(&array, "speed_upload", sizeof("speed_upload"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_HEADER_SIZE, &l)) {
-               add_assoc_long_ex(&array, "header_size", sizeof("header_size"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REQUEST_SIZE, &l)) {
-               add_assoc_long_ex(&array, "request_size", sizeof("request_size"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SSL_VERIFYRESULT, &l)) {
-               add_assoc_long_ex(&array, "ssl_verifyresult", sizeof("ssl_verifyresult"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_FILETIME, &l)) {
-               add_assoc_long_ex(&array, "filetime", sizeof("filetime"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
-               add_assoc_double_ex(&array, "content_length_download", sizeof("content_length_download"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONTENT_LENGTH_UPLOAD, &d)) {
-               add_assoc_double_ex(&array, "content_length_upload", sizeof("content_length_upload"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_STARTTRANSFER_TIME, &d)) {
-               add_assoc_double_ex(&array, "starttransfer_time", sizeof("starttransfer_time"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONTENT_TYPE, &c)) {
-               add_assoc_string_ex(&array, "content_type", sizeof("content_type"), c ? c : "", 1);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REDIRECT_TIME, &d)) {
-               add_assoc_double_ex(&array, "redirect_time", sizeof("redirect_time"), d);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REDIRECT_COUNT, &l)) {
-               add_assoc_long_ex(&array, "redirect_count", sizeof("redirect_count"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_HTTP_CONNECTCODE, &l)) {
-               add_assoc_long_ex(&array, "connect_code", sizeof("connect_code"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_HTTPAUTH_AVAIL, &l)) {
-               add_assoc_long_ex(&array, "httpauth_avail", sizeof("httpauth_avail"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PROXYAUTH_AVAIL, &l)) {
-               add_assoc_long_ex(&array, "proxyauth_avail", sizeof("proxyauth_avail"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_OS_ERRNO, &l)) {
-               add_assoc_long_ex(&array, "os_errno", sizeof("os_errno"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_NUM_CONNECTS, &l)) {
-               add_assoc_long_ex(&array, "num_connects", sizeof("num_connects"), l);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SSL_ENGINES, &s)) {
-               MAKE_STD_ZVAL(subarray);
-               array_init(subarray);
-               for (p = s; p; p = p->next) {
-                       if (p->data) {
-                               add_next_index_string(subarray, p->data, 1);
-                       }
-               }
-               add_assoc_zval_ex(&array, "ssl_engines", sizeof("ssl_engines"), subarray);
-               curl_slist_free_all(s);
-       }
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REDIRECT_URL, &c)) {
-               add_assoc_string_ex(&array, "redirect_url", sizeof("redirect_url"), c ? c : "", 1);
-       }
-#if PHP_HTTP_CURL_VERSION(7,19,0)
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRIMARY_IP, &c)) {
-               add_assoc_string_ex(&array, "primary_ip", sizeof("primary_ip"), c ? c : "", 1);
-       }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,19,0)
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_APPCONNECT_TIME, &d)) {
-               add_assoc_double_ex(&array, "appconnect_time", sizeof("appconnect_time"), d);
-       }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,19,4)
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONDITION_UNMET, &l)) {
-               add_assoc_long_ex(&array, "condition_unmet", sizeof("condition_unmet"), l);
-       }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,21,0)
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRIMARY_PORT, &l)) {
-               add_assoc_long_ex(&array, "primary_port", sizeof("primary_port"), l);
-       }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,21,0)
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_LOCAL_IP, &c)) {
-               add_assoc_string_ex(&array, "local_ip", sizeof("local_ip"), c ? c : "", 1);
-       }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,21,0)
-       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_LOCAL_PORT, &l)) {
-               add_assoc_long_ex(&array, "local_port", sizeof("local_port"), l);
-       }
-#endif
-
-       /* END::CURLINFO */
-
-#if PHP_HTTP_CURL_VERSION(7,34,0)
-       {
-               zval *ti_array;
-               struct curl_tlssessioninfo *ti;
-
-               if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_TLS_SESSION, &ti)) {
-                       const char *backend;
-
-                       MAKE_STD_ZVAL(subarray);
-                       ZVAL_NULL(subarray);
-                       MAKE_STD_ZVAL(ti_array);
-                       array_init(ti_array);
-
-                       switch (ti->backend) {
-                       case CURLSSLBACKEND_NONE:
-                               backend = "none";
-                               break;
-                       case CURLSSLBACKEND_OPENSSL:
-                               backend = "openssl";
-#ifdef PHP_HTTP_HAVE_OPENSSL
-                               {
-                                       SSL_CTX *ctx = ti->internals;
-
-                                       array_init(subarray);
-                                       add_assoc_long_ex(subarray, ZEND_STRS("number"), SSL_CTX_sess_number(ctx));
-                                       add_assoc_long_ex(subarray, ZEND_STRS("connect"), SSL_CTX_sess_connect(ctx));
-                                       add_assoc_long_ex(subarray, ZEND_STRS("connect_good"), SSL_CTX_sess_connect_good(ctx));
-                                       add_assoc_long_ex(subarray, ZEND_STRS("connect_renegotiate"), SSL_CTX_sess_connect_renegotiate(ctx));
-                                       add_assoc_long_ex(subarray, ZEND_STRS("hits"), SSL_CTX_sess_hits(ctx));
-                                       add_assoc_long_ex(subarray, ZEND_STRS("cache_full"), SSL_CTX_sess_cache_full(ctx));
-                               }
-#endif
-                               break;
-                       case CURLSSLBACKEND_GNUTLS:
-                               backend = "gnutls";
-#ifdef PHP_HTTP_HAVE_GNUTLS
-                               {
-                                       gnutls_session_t sess = ti->internals;
-                                       char *desc;
-
-                                       array_init(subarray);
-                                       if ((desc = gnutls_session_get_desc(sess))) {
-                                               add_assoc_string_ex(subarray, ZEND_STRS("desc"), desc, 1);
-                                               gnutls_free(desc);
-                                       }
-                                       add_assoc_bool_ex(subarray, ZEND_STRS("resumed"), gnutls_session_is_resumed(sess));
-                               }
-#endif
-                               break;
-                       case CURLSSLBACKEND_NSS:
-                               backend = "nss";
-                               break;
-#if !PHP_HTTP_CURL_VERSION(7,39,0)
-                       case CURLSSLBACKEND_QSOSSL:
-                               backend = "qsossl";
-                               break;
-#else
-                       case CURLSSLBACKEND_GSKIT:
-                               backend = "gskit";
-                               break;
-#endif
-                       case CURLSSLBACKEND_POLARSSL:
-                               backend = "polarssl";
-                               break;
-                       case CURLSSLBACKEND_CYASSL:
-                               backend = "cyassl";
-                               break;
-                       case CURLSSLBACKEND_SCHANNEL:
-                               backend = "schannel";
-                               break;
-                       case CURLSSLBACKEND_DARWINSSL:
-                               backend = "darwinssl";
-                               break;
-                       default:
-                               backend = "unknown";
-                       }
-                       add_assoc_string_ex(ti_array, ZEND_STRS("backend"), estrdup(backend), 0);
-                       add_assoc_zval_ex(ti_array, ZEND_STRS("internals"), subarray);
-                       add_assoc_zval_ex(&array, "tls_session", sizeof("tls_session"), ti_array);
-               }
-       }
-#endif
-
-#if (PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL)) || (PHP_HTTP_CURL_VERSION(7,34,0) && defined(PHP_HTTP_HAVE_NSS)) || (PHP_HTTP_CURL_VERSION(7,42,0) && defined(PHP_HTTP_HAVE_GNUTLS)) || (PHP_HTTP_CURL_VERSION(7,39,0) && defined(PHP_HTTP_HAVE_GSKIT))
-       {
-               int i;
-               zval *ci_array;
-               struct curl_certinfo *ci;
-               char *colon, *keyname;
-
-               if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CERTINFO, &ci)) {
-                       MAKE_STD_ZVAL(ci_array);
-                       array_init(ci_array);
-
-                       for (i = 0; i < ci->num_of_certs; ++i) {
-                               s = ci->certinfo[i];
-
-                               MAKE_STD_ZVAL(subarray);
-                               array_init(subarray);
-                               for (p = s; p; p = p->next) {
-                                       if (p->data) {
-                                               if ((colon = strchr(p->data, ':'))) {
-                                                       keyname = estrndup(p->data, colon - p->data);
-                                                       add_assoc_string_ex(subarray, keyname, colon - p->data + 1, colon + 1, 1);
-                                                       efree(keyname);
-                                               } else {
-                                                       add_next_index_string(subarray, p->data, 1);
-                                               }
-                                       }
-                               }
-                               add_next_index_zval(ci_array, subarray);
-                       }
-                       add_assoc_zval_ex(&array, "certinfo", sizeof("certinfo"), ci_array);
-               }
-       }
-#endif
-       {
-               php_http_curle_storage_t *st = php_http_curle_get_storage(ch);
-
-               add_assoc_long_ex(&array, "curlcode", sizeof("curlcode"), st->errorcode);
-               add_assoc_string_ex(&array, "error", sizeof("error"), st->errorbuffer, 1);
-       }
-
-       return SUCCESS;
-}
-
-static int compare_queue(php_http_client_enqueue_t *e, void *handle)
-{
-       return handle == ((php_http_client_curl_handler_t *) e->opaque)->handle;
-}
-
-static php_http_message_t *php_http_curlm_responseparser(php_http_client_curl_handler_t *h TSRMLS_DC)
-{
-       php_http_message_t *response;
-       php_http_header_parser_t parser;
-       zval *zh;
-
-       response = php_http_message_init(NULL, 0, h->response.body TSRMLS_CC);
-       php_http_header_parser_init(&parser TSRMLS_CC);
-       while (h->response.headers.used) {
-               php_http_header_parser_state_t st = php_http_header_parser_parse(&parser,
-                               &h->response.headers, PHP_HTTP_HEADER_PARSER_CLEANUP, &response->hdrs,
-                               (php_http_info_callback_t) php_http_message_info_callback, (void *) &response);
-               if (PHP_HTTP_HEADER_PARSER_STATE_FAILURE == st) {
-                       break;
-               }
-       }
-       php_http_header_parser_dtor(&parser);
-
-       /* move body to right message */
-       if (response->body != h->response.body) {
-               php_http_message_t *ptr = response;
-
-               while (ptr->parent) {
-                       ptr = ptr->parent;
-               }
-               php_http_message_body_free(&response->body);
-               response->body = ptr->body;
-               ptr->body = NULL;
-       }
-       php_http_message_body_addref(h->response.body);
-
-       /* let's update the response headers */
-       if ((zh = php_http_message_header(response, ZEND_STRL("Content-Length"), 1))) {
-               zend_hash_update(&response->hdrs, "X-Original-Content-Length", sizeof("X-Original-Content-Length"), &zh, sizeof(zval *), NULL);
-       }
-       if ((zh = php_http_message_header(response, ZEND_STRL("Transfer-Encoding"), 0))) {
-               zend_hash_update(&response->hdrs, "X-Original-Transfer-Encoding", sizeof("X-Original-Transfer-Encoding"), (void *) &zh, sizeof(zval *), NULL);
-               zend_hash_del(&response->hdrs, "Transfer-Encoding", sizeof("Transfer-Encoding"));
-       }
-       if ((zh = php_http_message_header(response, ZEND_STRL("Content-Range"), 0))) {
-               zend_hash_update(&response->hdrs, "X-Original-Content-Range", sizeof("X-Original-Content-Range"), &zh, sizeof(zval *), NULL);
-               zend_hash_del(&response->hdrs, "Content-Range", sizeof("Content-Range"));
-       }
-       if ((zh = php_http_message_header(response, ZEND_STRL("Content-Encoding"), 0))) {
-               zend_hash_update(&response->hdrs, "X-Original-Content-Encoding", sizeof("X-Original-Content-Encoding"), &zh, sizeof(zval *), NULL);
-               zend_hash_del(&response->hdrs, "Content-Encoding", sizeof("Content-Encoding"));
-       }
-       php_http_message_update_headers(response);
-
-       return response;
-}
-
-static void php_http_curlm_responsehandler(php_http_client_t *context)
-{
-       int err_count = 0, remaining = 0;
-       php_http_curle_storage_t *st, *err = NULL;
-       php_http_client_enqueue_t *enqueue;
-       php_http_client_curl_t *curl = context->ctx;
-       TSRMLS_FETCH_FROM_CTX(context->ts);
-
-       do {
-               CURLMsg *msg = curl_multi_info_read(curl->handle, &remaining);
-
-               if (msg && CURLMSG_DONE == msg->msg) {
-                       if (CURLE_OK != msg->data.result) {
-                               st = php_http_curle_get_storage(msg->easy_handle);
-                               st->errorcode = msg->data.result;
-
-                               /* defer the warnings/exceptions, so the callback is still called for this request */
-                               if (!err) {
-                                       err = ecalloc(remaining + 1, sizeof(*err));
-                               }
-                               memcpy(&err[err_count], st, sizeof(*st));
-                               if (st->url) {
-                                       err[err_count].url = estrdup(st->url);
-                               }
-                               err_count++;
-                       }
-
-                       if ((enqueue = php_http_client_enqueued(context, msg->easy_handle, compare_queue))) {
-                               php_http_client_curl_handler_t *handler = enqueue->opaque;
-                               php_http_message_t *response = php_http_curlm_responseparser(handler TSRMLS_CC);
-
-                               if (response) {
-                                       context->callback.response.func(context->callback.response.arg, context, &handler->queue, &response);
-                                       php_http_message_free(&response);
-                               }
-                       }
-               }
-       } while (remaining);
-
-       if (err_count) {
-               int i = 0;
-
-               do {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s; %s (%s)", curl_easy_strerror(err[i].errorcode), err[i].errorbuffer, STR_PTR(err[i].url));
-                       if (err[i].url) {
-                               efree(err[i].url);
-                       }
-               } while (++i < err_count);
-
-               efree(err);
-       }
-}
-
-#if PHP_HTTP_HAVE_EVENT
-
-typedef struct php_http_curlm_event {
-       struct event evnt;
-       php_http_client_t *context;
-} php_http_curlm_event_t;
-
-static inline int etoca(short action) {
-       switch (action & (EV_READ|EV_WRITE)) {
-               case EV_READ:
-                       return CURL_CSELECT_IN;
-                       break;
-               case EV_WRITE:
-                       return CURL_CSELECT_OUT;
-                       break;
-               case EV_READ|EV_WRITE:
-                       return CURL_CSELECT_IN|CURL_CSELECT_OUT;
-                       break;
-               default:
-                       return 0;
-       }
-}
-
-static void php_http_curlm_timeout_callback(int socket, short action, void *event_data)
-{
-       php_http_client_t *context = event_data;
-       php_http_client_curl_t *curl = context->ctx;
-
-#if DBG_EVENTS
-       fprintf(stderr, "T");
-#endif
-       if (curl->useevents) {
-               CURLMcode rc;
-               TSRMLS_FETCH_FROM_CTX(context->ts);
-
-               /* ignore and use -1,0 on timeout */
-               (void) socket;
-               (void) action;
-
-               while (CURLM_CALL_MULTI_PERFORM == (rc = curl_multi_socket_action(curl->handle, CURL_SOCKET_TIMEOUT, 0, &curl->unfinished)));
-
-               if (CURLM_OK != rc) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",  curl_multi_strerror(rc));
-               }
-
-               php_http_curlm_responsehandler(context);
-       }
-}
-
-static void php_http_curlm_event_callback(int socket, short action, void *event_data)
-{
-       php_http_client_t *context = event_data;
-       php_http_client_curl_t *curl = context->ctx;
-
-#if DBG_EVENTS
-       fprintf(stderr, "E");
-#endif
-       if (curl->useevents) {
-               CURLMcode rc = CURLM_OK;
-               TSRMLS_FETCH_FROM_CTX(context->ts);
-
-               while (CURLM_CALL_MULTI_PERFORM == (rc = curl_multi_socket_action(curl->handle, socket, etoca(action), &curl->unfinished)));
-
-               if (CURLM_OK != rc) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", curl_multi_strerror(rc));
-               }
-
-               php_http_curlm_responsehandler(context);
-
-               /* remove timeout if there are no transfers left */
-               if (!curl->unfinished && event_initialized(curl->timeout) && event_pending(curl->timeout, EV_TIMEOUT, NULL)) {
-                       event_del(curl->timeout);
-               }
-       }
-}
-
-static int php_http_curlm_socket_callback(CURL *easy, curl_socket_t sock, int action, void *socket_data, void *assign_data)
-{
-       php_http_client_t *context = socket_data;
-       php_http_client_curl_t *curl = context->ctx;
-
-#if DBG_EVENTS
-       fprintf(stderr, "S");
-#endif
-       if (curl->useevents) {
-               int events = EV_PERSIST;
-               php_http_curlm_event_t *ev = assign_data;
-               TSRMLS_FETCH_FROM_CTX(context->ts);
-
-               if (!ev) {
-                       ev = ecalloc(1, sizeof(php_http_curlm_event_t));
-                       ev->context = context;
-                       curl_multi_assign(curl->handle, sock, ev);
-               } else {
-                       event_del(&ev->evnt);
-               }
-
-               switch (action) {
-                       case CURL_POLL_IN:
-                               events |= EV_READ;
-                               break;
-                       case CURL_POLL_OUT:
-                               events |= EV_WRITE;
-                               break;
-                       case CURL_POLL_INOUT:
-                               events |= EV_READ|EV_WRITE;
-                               break;
-
-                       case CURL_POLL_REMOVE:
-                               efree(ev);
-                               /* no break */
-                       case CURL_POLL_NONE:
-                               return 0;
-
-                       default:
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown socket action %d", action);
-                               return -1;
-               }
-
-               event_assign(&ev->evnt, curl->evbase, sock, events, php_http_curlm_event_callback, context);
-               event_add(&ev->evnt, NULL);
-       }
-
-       return 0;
-}
-
-static void php_http_curlm_timer_callback(CURLM *multi, long timeout_ms, void *timer_data)
-{
-       php_http_client_t *context = timer_data;
-       php_http_client_curl_t *curl = context->ctx;
-
-#if DBG_EVENTS
-       fprintf(stderr, "\ntimer <- timeout_ms: %ld\n", timeout_ms);
-#endif
-       if (curl->useevents) {
-
-               if (timeout_ms < 0) {
-                       php_http_curlm_timeout_callback(CURL_SOCKET_TIMEOUT, /*EV_READ|EV_WRITE*/0, context);
-               } else if (timeout_ms > 0 || !event_initialized(curl->timeout) || !event_pending(curl->timeout, EV_TIMEOUT, NULL)) {
-                       struct timeval timeout;
-
-                       if (!event_initialized(curl->timeout)) {
-                               event_assign(curl->timeout, curl->evbase, CURL_SOCKET_TIMEOUT, 0, php_http_curlm_timeout_callback, context);
-                       }
-
-                       timeout.tv_sec = timeout_ms / 1000;
-                       timeout.tv_usec = (timeout_ms % 1000) * 1000;
-
-                       event_add(curl->timeout, &timeout);
-               }
-       }
-}
-
-#endif /* HAVE_EVENT */
-
-/* curl options */
-
-static php_http_options_t php_http_curle_options, php_http_curlm_options;
-
-#define PHP_HTTP_CURLE_OPTION_CHECK_STRLEN             0x0001
-#define PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR            0x0002
-#define PHP_HTTP_CURLE_OPTION_TRANSFORM_MS             0x0004
-
-static ZEND_RESULT_CODE php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-
-       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_SSL_VERIFYHOST, Z_BVAL_P(val) ? 2 : 0)) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_cookiestore(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-       php_http_curle_storage_t *storage = php_http_curle_get_storage(curl->handle);
-
-       if (storage->cookiestore) {
-               pefree(storage->cookiestore, 1);
-       }
-       if (val && Z_STRLEN_P(val)) {
-               storage->cookiestore = pestrndup(Z_STRVAL_P(val), Z_STRLEN_P(val), 1);
-       } else {
-               storage->cookiestore = NULL;
-       }
-       if (    CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore)
-               ||      CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore)
-       ) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_cookies(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       if (val && Z_TYPE_P(val) != IS_NULL) {
-               if (curl->options.encode_cookies) {
-                       if (SUCCESS == php_http_url_encode_hash_ex(HASH_OF(val), &curl->options.cookies, ZEND_STRL(";"), ZEND_STRL("="), NULL, 0 TSRMLS_CC)) {
-                               php_http_buffer_fix(&curl->options.cookies);
-                               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, curl->options.cookies.data)) {
-                                       return FAILURE;
-                               }
-                       } else {
-                               return FAILURE;
-                       }
-               } else {
-                       HashPosition pos;
-                       php_http_array_hashkey_t cookie_key = php_http_array_hashkey_init(0);
-                       zval **cookie_val;
-
-                       FOREACH_KEYVAL(pos, val, cookie_key, cookie_val) {
-                               zval *zv = php_http_ztyp(IS_STRING, *cookie_val);
-
-                               php_http_array_hashkey_stringify(&cookie_key);
-                               php_http_buffer_appendf(&curl->options.cookies, "%s=%s; ", cookie_key.str, Z_STRVAL_P(zv));
-                               php_http_array_hashkey_stringfree(&cookie_key);
-
-                               zval_ptr_dtor(&zv);
-                       }
-
-                       php_http_buffer_fix(&curl->options.cookies);
-                       if (curl->options.cookies.used) {
-                               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, curl->options.cookies.data)) {
-                                       return FAILURE;
-                               }
-                       }
-               }
-       } else {
-               php_http_buffer_reset(&curl->options.cookies);
-               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, NULL)) {
-                       return FAILURE;
-               }
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_encodecookies(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-
-       curl->options.encode_cookies = Z_BVAL_P(val);
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_lastmodified(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       if (Z_LVAL_P(val)) {
-               if (Z_LVAL_P(val) > 0) {
-                       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TIMEVALUE, Z_LVAL_P(val))) {
-                               return FAILURE;
-                       }
-               } else {
-                       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TIMEVALUE, (long) sapi_get_request_time(TSRMLS_C) + Z_LVAL_P(val))) {
-                               return FAILURE;
-                       }
-               }
-               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TIMECONDITION, (long) (curl->options.range_request ? CURL_TIMECOND_IFUNMODSINCE : CURL_TIMECOND_IFMODSINCE))) {
-                       return FAILURE;
-               }
-       } else {
-               if (    CURLE_OK != curl_easy_setopt(ch, CURLOPT_TIMEVALUE, 0)
-                       ||      CURLE_OK != curl_easy_setopt(ch, CURLOPT_TIMECONDITION, 0)
-               ) {
-                       return FAILURE;
-               }
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_compress(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-
-#if !PHP_HTTP_CURL_VERSION(7,21,6)
-#      define CURLOPT_ACCEPT_ENCODING CURLOPT_ENCODING
-#endif
-       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_ACCEPT_ENCODING, Z_BVAL_P(val) ? "" : NULL)) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_etag(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       php_http_buffer_t header;
-
-       if (Z_STRLEN_P(val)) {
-               zend_bool is_quoted = !((Z_STRVAL_P(val)[0] != '"') || (Z_STRVAL_P(val)[Z_STRLEN_P(val)-1] != '"'));
-               php_http_buffer_init(&header);
-               php_http_buffer_appendf(&header, is_quoted?"%s: %s":"%s: \"%s\"", curl->options.range_request?"If-Match":"If-None-Match", Z_STRVAL_P(val));
-               php_http_buffer_fix(&header);
-               curl->options.headers = curl_slist_append(curl->options.headers, header.data);
-               php_http_buffer_dtor(&header);
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_range(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       php_http_buffer_reset(&curl->options.ranges);
-
-       if (val && Z_TYPE_P(val) != IS_NULL) {
-               HashPosition pos;
-               zval **rr, **rb, **re;
-
-               FOREACH_VAL(pos, val, rr) {
-                       if (Z_TYPE_PP(rr) == IS_ARRAY) {
-                               if (2 == php_http_array_list(Z_ARRVAL_PP(rr) TSRMLS_CC, 2, &rb, &re)) {
-                                       if (    ((Z_TYPE_PP(rb) == IS_LONG) || ((Z_TYPE_PP(rb) == IS_STRING) && is_numeric_string(Z_STRVAL_PP(rb), Z_STRLEN_PP(rb), NULL, NULL, 1))) &&
-                                                       ((Z_TYPE_PP(re) == IS_LONG) || ((Z_TYPE_PP(re) == IS_STRING) && is_numeric_string(Z_STRVAL_PP(re), Z_STRLEN_PP(re), NULL, NULL, 1)))) {
-                                               zval *rbl = php_http_ztyp(IS_LONG, *rb);
-                                               zval *rel = php_http_ztyp(IS_LONG, *re);
-
-                                               if ((Z_LVAL_P(rbl) >= 0) && (Z_LVAL_P(rel) >= 0)) {
-                                                       php_http_buffer_appendf(&curl->options.ranges, "%ld-%ld,", Z_LVAL_P(rbl), Z_LVAL_P(rel));
-                                               }
-                                               zval_ptr_dtor(&rbl);
-                                               zval_ptr_dtor(&rel);
-                                       }
-
-                               }
-                       }
-               }
-
-               if (curl->options.ranges.used) {
-                       curl->options.range_request = 1;
-                       /* ditch last comma */
-                       curl->options.ranges.data[curl->options.ranges.used - 1] = '\0';
-               }
-       }
-
-       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RANGE, curl->options.ranges.data)) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_resume(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-
-       if (Z_LVAL_P(val) > 0) {
-               curl->options.range_request = 1;
-       }
-       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RESUME_FROM, Z_LVAL_P(val))) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_retrydelay(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-
-       curl->options.retry.delay = Z_DVAL_P(val);
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_retrycount(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-
-       curl->options.retry.count = Z_LVAL_P(val);
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_redirect(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-
-       if (    CURLE_OK != curl_easy_setopt(ch, CURLOPT_FOLLOWLOCATION, Z_LVAL_P(val) ? 1L : 0L)
-               ||      CURLE_OK != curl_easy_setopt(ch, CURLOPT_MAXREDIRS, curl->options.redirects = Z_LVAL_P(val))
-       ) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curle_option_set_portrange(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-       long localport = 0, localportrange = 0;
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       if (val && Z_TYPE_P(val) != IS_NULL) {
-               zval **z_port_start, *zps_copy = NULL, **z_port_end, *zpe_copy = NULL;
-
-               switch (php_http_array_list(Z_ARRVAL_P(val) TSRMLS_CC, 2, &z_port_start, &z_port_end)) {
-               case 2:
-                       zps_copy = php_http_ztyp(IS_LONG, *z_port_start);
-                       zpe_copy = php_http_ztyp(IS_LONG, *z_port_end);
-                       localportrange = labs(Z_LVAL_P(zps_copy)-Z_LVAL_P(zpe_copy))+1L;
-                       /* no break */
-               case 1:
-                       if (!zps_copy) {
-                               zps_copy = php_http_ztyp(IS_LONG, *z_port_start);
-                       }
-                       localport = (zpe_copy && Z_LVAL_P(zpe_copy) > 0) ? MIN(Z_LVAL_P(zps_copy), Z_LVAL_P(zpe_copy)) : Z_LVAL_P(zps_copy);
-                       zval_ptr_dtor(&zps_copy);
-                       if (zpe_copy) {
-                               zval_ptr_dtor(&zpe_copy);
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
-       if (    CURLE_OK != curl_easy_setopt(ch, CURLOPT_LOCALPORT, localport)
-               ||      CURLE_OK != curl_easy_setopt(ch, CURLOPT_LOCALPORTRANGE, localportrange)
-       ) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-
-#if PHP_HTTP_CURL_VERSION(7,37,0)
-static ZEND_RESULT_CODE php_http_curle_option_set_proxyheader(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       if (val && Z_TYPE_P(val) != IS_NULL) {
-               php_http_array_hashkey_t header_key = php_http_array_hashkey_init(0);
-               zval **header_val, *header_cpy;
-               HashPosition pos;
-               php_http_buffer_t header;
-
-               php_http_buffer_init(&header);
-               FOREACH_KEYVAL(pos, val, header_key, header_val) {
-                       if (header_key.type == HASH_KEY_IS_STRING) {
-                               header_cpy = php_http_ztyp(IS_STRING, *header_val);
-                               php_http_buffer_appendf(&header, "%s: %s", header_key.str, Z_STRVAL_P(header_cpy));
-                               php_http_buffer_fix(&header);
-                               curl->options.proxyheaders = curl_slist_append(curl->options.proxyheaders, header.data);
-                               php_http_buffer_reset(&header);
-
-                               zval_ptr_dtor(&header_cpy);
-                       }
-               }
-               php_http_buffer_dtor(&header);
-       }
-       if (CURLE_OK != curl_easy_setopt(curl->handle, CURLOPT_PROXYHEADER, curl->options.proxyheaders)) {
-               return FAILURE;
-       }
-       if (CURLE_OK != curl_easy_setopt(curl->handle, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE)) {
-               curl_easy_setopt(curl->handle, CURLOPT_PROXYHEADER, NULL);
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-#endif
-
-#if PHP_HTTP_CURL_VERSION(7,21,3)
-static ZEND_RESULT_CODE php_http_curle_option_set_resolve(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       if (val && Z_TYPE_P(val) != IS_NULL) {
-               php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
-               HashPosition pos;
-               zval **data;
-
-               FOREACH_KEYVAL(pos, val, key, data) {
-                       zval *cpy = php_http_ztyp(IS_STRING, *data);
-                       curl->options.resolve = curl_slist_append(curl->options.resolve, Z_STRVAL_P(cpy));
-                       zval_ptr_dtor(&cpy);
-               }
-
-               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RESOLVE, curl->options.resolve)) {
-                       return FAILURE;
-               }
-       } else {
-               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RESOLVE, NULL)) {
-                       return FAILURE;
-               }
-       }
-       return SUCCESS;
-}
-#endif
-
-#if PHP_HTTP_CURL_VERSION(7,21,4) && defined(PHP_HTTP_CURL_TLSAUTH_SRP)
-static ZEND_RESULT_CODE php_http_curle_option_set_ssl_tlsauthtype(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-
-       if (val && Z_LVAL_P(val)) {
-               switch (Z_LVAL_P(val)) {
-               case CURL_TLSAUTH_SRP:
-                       if (CURLE_OK == curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, PHP_HTTP_CURL_TLSAUTH_SRP)) {
-                               return SUCCESS;
-                       }
-                       /* no break */
-               default:
-                       return FAILURE;
-               }
-       }
-       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, PHP_HTTP_CURL_TLSAUTH_DEF)) {
-               return FAILURE;
-       }
-       return SUCCESS;
-}
-#endif
-
-static void php_http_curle_options_init(php_http_options_t *registry TSRMLS_DC)
-{
-       php_http_option_t *opt;
-
-       /* url options */
-#if PHP_HTTP_CURL_VERSION(7,42,0)
-       php_http_option_register(registry, ZEND_STRL("path_as_is"), CURLOPT_PATH_AS_IS, IS_BOOL);
-#endif
-
-       /* proxy */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("proxyhost"), CURLOPT_PROXY, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-       php_http_option_register(registry, ZEND_STRL("proxytype"), CURLOPT_PROXYTYPE, IS_LONG);
-       php_http_option_register(registry, ZEND_STRL("proxyport"), CURLOPT_PROXYPORT, IS_LONG);
-       if ((opt = php_http_option_register(registry, ZEND_STRL("proxyauth"), CURLOPT_PROXYUSERPWD, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("proxyauthtype"), CURLOPT_PROXYAUTH, IS_LONG))) {
-               Z_LVAL(opt->defval) = CURLAUTH_ANYSAFE;
-       }
-       php_http_option_register(registry, ZEND_STRL("proxytunnel"), CURLOPT_HTTPPROXYTUNNEL, IS_BOOL);
-#if PHP_HTTP_CURL_VERSION(7,19,4)
-       php_http_option_register(registry, ZEND_STRL("noproxy"), CURLOPT_NOPROXY, IS_STRING);
-#endif
-
-#if PHP_HTTP_CURL_VERSION(7,37,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("proxyheader"), CURLOPT_PROXYHEADER, IS_ARRAY))) {
-               opt->setter = php_http_curle_option_set_proxyheader;
-       }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,43,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("proxy_service_name"), CURLOPT_PROXY_SERVICE_NAME, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-#endif
-
-#if PHP_HTTP_CURL_VERSION(7,40,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("unix_socket_path"), CURLOPT_UNIX_SOCKET_PATH, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-       }
-#endif
-
-       /* dns */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("dns_cache_timeout"), CURLOPT_DNS_CACHE_TIMEOUT, IS_LONG))) {
-               Z_LVAL(opt->defval) = 60;
-       }
-       php_http_option_register(registry, ZEND_STRL("ipresolve"), CURLOPT_IPRESOLVE, IS_LONG);
-#if PHP_HTTP_CURL_VERSION(7,21,3)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("resolve"), CURLOPT_RESOLVE, IS_ARRAY))) {
-               opt->setter = php_http_curle_option_set_resolve;
-       }
-#endif
-#if PHP_HTTP_HAVE_ARES
-# if PHP_HTTP_CURL_VERSION(7,24,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("dns_servers"), CURLOPT_DNS_SERVERS, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-# endif
-# if PHP_HTTP_CURL_VERSION(7,33,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("dns_interface"), CURLOPT_DNS_INTERFACE, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("dns_local_ip4"), CURLOPT_DNS_LOCAL_IP4, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("dns_local_ip6"), CURLOPT_DNS_LOCAL_IP6, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-# endif
-#endif
-
-       /* limits */
-       php_http_option_register(registry, ZEND_STRL("low_speed_limit"), CURLOPT_LOW_SPEED_LIMIT, IS_LONG);
-       php_http_option_register(registry, ZEND_STRL("low_speed_time"), CURLOPT_LOW_SPEED_TIME, IS_LONG);
-
-       /* LSF weirdance
-       php_http_option_register(registry, ZEND_STRL("max_send_speed"), CURLOPT_MAX_SEND_SPEED_LARGE, IS_LONG);
-       php_http_option_register(registry, ZEND_STRL("max_recv_speed"), CURLOPT_MAX_RECV_SPEED_LARGE, IS_LONG);
-       */
-
-       /* connection handling */
-       /* crashes
-       if ((opt = php_http_option_register(registry, ZEND_STRL("maxconnects"), CURLOPT_MAXCONNECTS, IS_LONG))) {
-               Z_LVAL(opt->defval) = 5;
-       }
-       */
-       php_http_option_register(registry, ZEND_STRL("fresh_connect"), CURLOPT_FRESH_CONNECT, IS_BOOL);
-       php_http_option_register(registry, ZEND_STRL("forbid_reuse"), CURLOPT_FORBID_REUSE, IS_BOOL);
-
-       /* outgoing interface */
-       php_http_option_register(registry, ZEND_STRL("interface"), CURLOPT_INTERFACE, IS_STRING);
-       if ((opt = php_http_option_register(registry, ZEND_STRL("portrange"), CURLOPT_LOCALPORT, IS_ARRAY))) {
-               opt->setter = php_http_curle_option_set_portrange;
-       }
-
-       /* another endpoint port */
-       php_http_option_register(registry, ZEND_STRL("port"), CURLOPT_PORT, IS_LONG);
-
-       /* RFC4007 zone_id */
-#if PHP_HTTP_CURL_VERSION(7,19,0)
-       php_http_option_register(registry, ZEND_STRL("address_scope"), CURLOPT_ADDRESS_SCOPE, IS_LONG);
-#endif
-
-       /* auth */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("httpauth"), CURLOPT_USERPWD, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("httpauthtype"), CURLOPT_HTTPAUTH, IS_LONG))) {
-               Z_LVAL(opt->defval) = CURLAUTH_ANYSAFE;
-       }
-#if PHP_HTTP_CURL_VERSION(7,43,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("service_name"), CURLOPT_SERVICE_NAME, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-#endif
-
-       /* redirects */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("redirect"), CURLOPT_FOLLOWLOCATION, IS_LONG))) {
-               opt->setter = php_http_curle_option_set_redirect;
-       }
-       php_http_option_register(registry, ZEND_STRL("unrestricted_auth"), CURLOPT_UNRESTRICTED_AUTH, IS_BOOL);
-#if PHP_HTTP_CURL_VERSION(7,19,1)
-       php_http_option_register(registry, ZEND_STRL("postredir"), CURLOPT_POSTREDIR, IS_LONG);
-#endif
-
-       /* retries */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("retrycount"), 0, IS_LONG))) {
-               opt->setter = php_http_curle_option_set_retrycount;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("retrydelay"), 0, IS_DOUBLE))) {
-               opt->setter = php_http_curle_option_set_retrydelay;
-       }
-
-       /* referer */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("referer"), CURLOPT_REFERER, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("autoreferer"), CURLOPT_AUTOREFERER, IS_BOOL))) {
-               ZVAL_BOOL(&opt->defval, 1);
-       }
-
-       /* useragent */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("useragent"), CURLOPT_USERAGENT, IS_STRING))) {
-               /* don't check strlen, to allow sending no useragent at all */
-               ZVAL_STRING(&opt->defval,
-                               "PECL_HTTP/" PHP_PECL_HTTP_VERSION " "
-                               "PHP/" PHP_VERSION " "
-                               "libcurl/" LIBCURL_VERSION
-                       , 0);
-       }
-
-       /* resume */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("resume"), CURLOPT_RESUME_FROM, IS_LONG))) {
-               opt->setter = php_http_curle_option_set_resume;
-       }
-       /* ranges */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("range"), CURLOPT_RANGE, IS_ARRAY))) {
-               opt->setter = php_http_curle_option_set_range;
-       }
-
-       /* etag */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("etag"), 0, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-               opt->setter = php_http_curle_option_set_etag;
-       }
-
-       /* compression */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("compress"), 0, IS_BOOL))) {
-               opt->setter = php_http_curle_option_set_compress;
-       }
-
-       /* lastmodified */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("lastmodified"), 0, IS_LONG))) {
-               opt->setter = php_http_curle_option_set_lastmodified;
-       }
-
-       /* cookies */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("encodecookies"), 0, IS_BOOL))) {
-               opt->setter = php_http_curle_option_set_encodecookies;
-               ZVAL_BOOL(&opt->defval, 1);
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("cookies"), 0, IS_ARRAY))) {
-               opt->setter = php_http_curle_option_set_cookies;
-       }
-
-       /* cookiesession, don't load session cookies from cookiestore */
-       php_http_option_register(registry, ZEND_STRL("cookiesession"), CURLOPT_COOKIESESSION, IS_BOOL);
-       /* cookiestore, read initial cookies from that file and store cookies back into that file */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("cookiestore"), 0, IS_STRING))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-               opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               opt->setter = php_http_curle_option_set_cookiestore;
-       }
-
-       /* maxfilesize */
-       php_http_option_register(registry, ZEND_STRL("maxfilesize"), CURLOPT_MAXFILESIZE, IS_LONG);
-
-       /* http protocol version */
-       php_http_option_register(registry, ZEND_STRL("protocol"), CURLOPT_HTTP_VERSION, IS_LONG);
-
-       /* timeouts */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("timeout"), CURLOPT_TIMEOUT_MS, IS_DOUBLE))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_TRANSFORM_MS;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("connecttimeout"), CURLOPT_CONNECTTIMEOUT_MS, IS_DOUBLE))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_TRANSFORM_MS;
-               Z_DVAL(opt->defval) = 3;
-       }
-#if PHP_HTTP_CURL_VERSION(7,36,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("expect_100_timeout"), CURLOPT_EXPECT_100_TIMEOUT_MS, IS_DOUBLE))) {
-               opt->flags |= PHP_HTTP_CURLE_OPTION_TRANSFORM_MS;
-               Z_DVAL(opt->defval) = 1;
-       }
-#endif
-
-       /* tcp */
-       php_http_option_register(registry, ZEND_STRL("tcp_nodelay"), CURLOPT_TCP_NODELAY, IS_BOOL);
-#if PHP_HTTP_CURL_VERSION(7,25,0)
-       php_http_option_register(registry, ZEND_STRL("tcp_keepalive"), CURLOPT_TCP_KEEPALIVE, IS_BOOL);
-       if ((opt = php_http_option_register(registry, ZEND_STRL("tcp_keepidle"), CURLOPT_TCP_KEEPIDLE, IS_LONG))) {
-               Z_LVAL(opt->defval) = 60;
-       }
-       if ((opt = php_http_option_register(registry, ZEND_STRL("tcp_keepintvl"), CURLOPT_TCP_KEEPINTVL, IS_LONG))) {
-               Z_LVAL(opt->defval) = 60;
-       }
-#endif
-
-       /* ssl */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("ssl"), 0, IS_ARRAY))) {
-               registry = &opt->suboptions;
-
-               if ((opt = php_http_option_register(registry, ZEND_STRL("cert"), CURLOPT_SSLCERT, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("certtype"), CURLOPT_SSLCERTTYPE, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       ZVAL_STRING(&opt->defval, "PEM", 0);
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("key"), CURLOPT_SSLKEY, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("keytype"), CURLOPT_SSLKEYTYPE, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       ZVAL_STRING(&opt->defval, "PEM", 0);
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("keypasswd"), CURLOPT_SSLKEYPASSWD, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-               }
-               php_http_option_register(registry, ZEND_STRL("engine"), CURLOPT_SSLENGINE, IS_STRING);
-               php_http_option_register(registry, ZEND_STRL("version"), CURLOPT_SSLVERSION, IS_LONG);
-               if ((opt = php_http_option_register(registry, ZEND_STRL("verifypeer"), CURLOPT_SSL_VERIFYPEER, IS_BOOL))) {
-                       ZVAL_BOOL(&opt->defval, 1);
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("verifyhost"), CURLOPT_SSL_VERIFYHOST, IS_BOOL))) {
-                       ZVAL_BOOL(&opt->defval, 1);
-                       opt->setter = php_http_curle_option_set_ssl_verifyhost;
-               }
-#if PHP_HTTP_CURL_VERSION(7,41,0)
-               php_http_option_register(registry, ZEND_STRL("verifystatus"), CURLOPT_SSL_VERIFYSTATUS, IS_BOOL);
-#endif
-               php_http_option_register(registry, ZEND_STRL("cipher_list"), CURLOPT_SSL_CIPHER_LIST, IS_STRING);
-               if ((opt = php_http_option_register(registry, ZEND_STRL("cainfo"), CURLOPT_CAINFO, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-#ifdef PHP_HTTP_CURL_CAINFO
-                       ZVAL_STRING(&opt->defval, PHP_HTTP_CURL_CAINFO, 0);
-#endif
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("capath"), CURLOPT_CAPATH, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("random_file"), CURLOPT_RANDOM_FILE, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("egdsocket"), CURLOPT_EGDSOCKET, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-#if PHP_HTTP_CURL_VERSION(7,19,0)
-               if ((opt = php_http_option_register(registry, ZEND_STRL("issuercert"), CURLOPT_ISSUERCERT, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-#      ifdef PHP_HTTP_HAVE_OPENSSL
-               if ((opt = php_http_option_register(registry, ZEND_STRL("crlfile"), CURLOPT_CRLFILE, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-#      endif
-#endif
-#if (PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL)) || (PHP_HTTP_CURL_VERSION(7,34,0) && defined(PHP_HTTP_HAVE_NSS)) || (PHP_HTTP_CURL_VERSION(7,42,0) && defined(PHP_HTTP_HAVE_GNUTLS)) || (PHP_HTTP_CURL_VERSION(7,39,0) && defined(PHP_HTTP_HAVE_GSKIT))
-               php_http_option_register(registry, ZEND_STRL("certinfo"), CURLOPT_CERTINFO, IS_BOOL);
-#endif
-#if PHP_HTTP_CURL_VERSION(7,36,0)
-               if ((opt = php_http_option_register(registry, ZEND_STRL("enable_npn"), CURLOPT_SSL_ENABLE_NPN, IS_BOOL))) {
-                       ZVAL_BOOL(&opt->defval, 1);
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("enable_alpn"), CURLOPT_SSL_ENABLE_ALPN, IS_BOOL))) {
-                       ZVAL_BOOL(&opt->defval, 1);
-               }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,39,0)
-               /* FIXME: see http://curl.haxx.se/libcurl/c/CURLOPT_PINNEDPUBLICKEY.html#AVAILABILITY */
-               if ((opt = php_http_option_register(registry, ZEND_STRL("pinned_publickey"), CURLOPT_PINNEDPUBLICKEY, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
-               }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,21,4) && defined(PHP_HTTP_CURL_TLSAUTH_SRP)
-               if ((opt = php_http_option_register(registry, ZEND_STRL("tlsauthtype"), CURLOPT_TLSAUTH_TYPE, IS_LONG))) {
-                       opt->setter = php_http_curle_option_set_ssl_tlsauthtype;
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("tlsauthuser"), CURLOPT_TLSAUTH_USERNAME, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-               }
-               if ((opt = php_http_option_register(registry, ZEND_STRL("tlsauthpass"), CURLOPT_TLSAUTH_PASSWORD, IS_STRING))) {
-                       opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
-               }
-#endif
-#if PHP_HTTP_CURL_VERSION(7,42,0) && (defined(PHP_HTTP_HAVE_NSS) || defined(PHP_HTTP_HAVE_DARWINSSL))
-               php_http_option_register(registry, ZEND_STRL("falsestart"), CURLOPT_SSL_FALSESTART, IS_BOOL);
-#endif
-       }
-}
-
-static zval *php_http_curle_get_option(php_http_option_t *opt, HashTable *options, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       zval *option;
-
-       if ((option = php_http_option_get(opt, options, NULL))) {
-               option = php_http_ztyp(opt->type, option);
-               zend_hash_quick_update(&curl->options.cache, opt->name.s, opt->name.l, opt->name.h, &option, sizeof(zval *), NULL);
-       }
-       return option;
-}
-
-static ZEND_RESULT_CODE php_http_curle_set_option(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_curl_handler_t *curl = userdata;
-       CURL *ch = curl->handle;
-       zval tmp;
-       CURLcode rc = CURLE_OK;
-       ZEND_RESULT_CODE rv = SUCCESS;
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       if (!val) {
-               val = &opt->defval;
-       }
-
-       switch (opt->type) {
-       case IS_BOOL:
-               if (opt->setter) {
-                       rv = opt->setter(opt, val, curl);
-               } else if (CURLE_OK != curl_easy_setopt(ch, opt->option, (long) Z_BVAL_P(val))) {
-                       rv = FAILURE;
-               }
-               break;
-
-       case IS_LONG:
-               if (opt->setter) {
-                       rv = opt->setter(opt, val, curl);
-               } else if (CURLE_OK != curl_easy_setopt(ch, opt->option, Z_LVAL_P(val))) {
-                       rv = FAILURE;
-               }
-               break;
-
-       case IS_STRING:
-               if (opt->setter) {
-                       rv = opt->setter(opt, val, curl);
-               } else if ((opt->flags & PHP_HTTP_CURLE_OPTION_CHECK_STRLEN) && !Z_STRLEN_P(val)) {
-                       if (CURLE_OK != (rc = curl_easy_setopt(ch, opt->option, NULL))) {
-                               rv = FAILURE;
-                       }
-               } else if ((opt->flags & PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR) && Z_STRVAL_P(val) && SUCCESS != php_check_open_basedir(Z_STRVAL_P(val) TSRMLS_CC)) {
-                       if (CURLE_OK != (rc = curl_easy_setopt(ch, opt->option, NULL))) {
-                               rv = FAILURE;
-                       }
-               } else if (CURLE_OK != (rc = curl_easy_setopt(ch, opt->option, Z_STRVAL_P(val)))) {
-                       rv = FAILURE;
-               }
-               break;
-
-       case IS_DOUBLE:
-               if (opt->flags & PHP_HTTP_CURLE_OPTION_TRANSFORM_MS) {
-                       tmp = *val;
-                       Z_DVAL(tmp) *= 1000;
-                       val = &tmp;
-               }
-               if (opt->setter) {
-                       rv = opt->setter(opt, val, curl);
-               } else if (CURLE_OK != curl_easy_setopt(ch, opt->option, (long) Z_DVAL_P(val))) {
-                       rv = FAILURE;
-               }
-               break;
-
-       case IS_ARRAY:
-               if (opt->setter) {
-                       rv = opt->setter(opt, val, curl);
-               } else if (Z_TYPE_P(val) != IS_NULL) {
-                       rv = php_http_options_apply(&opt->suboptions, Z_ARRVAL_P(val), curl);
-               }
-               break;
-
-       default:
-               if (opt->setter) {
-                       rv = opt->setter(opt, val, curl);
-               } else {
-                       rv = FAILURE;
-               }
-               break;
-       }
-       if (rv != SUCCESS) {
-               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not set option %s (%s)", opt->name.s, curl_easy_strerror(rc));
-       }
-       return rv;
-}
-
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-static ZEND_RESULT_CODE php_http_curlm_option_set_pipelining_bl(php_http_option_t *opt, zval *value, void *userdata)
-{
-       php_http_client_t *client = userdata;
-       php_http_client_curl_t *curl = client->ctx;
-       CURLM *ch = curl->handle;
-       HashTable tmp_ht;
-       char **bl = NULL;
-       TSRMLS_FETCH_FROM_CTX(client->ts);
-
-       /* array of char *, ending with a NULL */
-       if (value && Z_TYPE_P(value) != IS_NULL) {
-               zval **entry;
-               HashPosition pos;
-               HashTable *ht = HASH_OF(value);
-               int c = zend_hash_num_elements(ht);
-               char **ptr = ecalloc(c + 1, sizeof(char *));
-
-               bl = ptr;
-
-               zend_hash_init(&tmp_ht, c, NULL, ZVAL_PTR_DTOR, 0);
-               array_join(ht, &tmp_ht, 0, ARRAY_JOIN_STRINGIFY);
-
-               FOREACH_HASH_VAL(pos, &tmp_ht, entry) {
-                       *ptr++ = Z_STRVAL_PP(entry);
-               }
-       }
-
-       if (CURLM_OK != curl_multi_setopt(ch, opt->option, bl)) {
-               if (bl) {
-                       efree(bl);
-                       zend_hash_destroy(&tmp_ht);
-               }
-               return FAILURE;
-       }
-
-       if (bl) {
-               efree(bl);
-               zend_hash_destroy(&tmp_ht);
-       }
-       return SUCCESS;
-}
-#endif
-
-#if PHP_HTTP_HAVE_EVENT
-static inline ZEND_RESULT_CODE php_http_curlm_use_eventloop(php_http_client_t *h, zend_bool enable)
-{
-       php_http_client_curl_t *curl = h->ctx;
-
-       if ((curl->useevents = enable)) {
-               if (!curl->evbase) {
-                       curl->evbase = event_base_new();
-               }
-               if (!curl->timeout) {
-                       curl->timeout = ecalloc(1, sizeof(struct event));
-               }
-               curl_multi_setopt(curl->handle, CURLMOPT_SOCKETDATA, h);
-               curl_multi_setopt(curl->handle, CURLMOPT_SOCKETFUNCTION, php_http_curlm_socket_callback);
-               curl_multi_setopt(curl->handle, CURLMOPT_TIMERDATA, h);
-               curl_multi_setopt(curl->handle, CURLMOPT_TIMERFUNCTION, php_http_curlm_timer_callback);
-       } else {
-               curl_multi_setopt(curl->handle, CURLMOPT_SOCKETDATA, NULL);
-               curl_multi_setopt(curl->handle, CURLMOPT_SOCKETFUNCTION, NULL);
-               curl_multi_setopt(curl->handle, CURLMOPT_TIMERDATA, NULL);
-               curl_multi_setopt(curl->handle, CURLMOPT_TIMERFUNCTION, NULL);
-       }
-
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_curlm_option_set_use_eventloop(php_http_option_t *opt, zval *value, void *userdata)
-{
-       php_http_client_t *client = userdata;
-
-       return php_http_curlm_use_eventloop(client, value && Z_BVAL_P(value));
-}
-#endif
-
-static void php_http_curlm_options_init(php_http_options_t *registry TSRMLS_DC)
-{
-       php_http_option_t *opt;
-
-       /* set size of connection cache */
-       if ((opt = php_http_option_register(registry, ZEND_STRL("maxconnects"), CURLMOPT_MAXCONNECTS, IS_LONG))) {
-               /* -1 == default, 0 == unlimited */
-               ZVAL_LONG(&opt->defval, -1);
-       }
-       /* set max number of connections to a single host */
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-       php_http_option_register(registry, ZEND_STRL("max_host_connections"), CURLMOPT_MAX_HOST_CONNECTIONS, IS_LONG);
-#endif
-       /* maximum number of requests in a pipeline */
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("max_pipeline_length"), CURLMOPT_MAX_PIPELINE_LENGTH, IS_LONG))) {
-               ZVAL_LONG(&opt->defval, 5);
-       }
-#endif
-       /* max simultaneously open connections */
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-       php_http_option_register(registry, ZEND_STRL("max_total_connections"), CURLMOPT_MAX_TOTAL_CONNECTIONS, IS_LONG);
-#endif
-       /* enable/disable HTTP pipelining */
-       php_http_option_register(registry, ZEND_STRL("pipelining"), CURLMOPT_PIPELINING, IS_BOOL);
-       /* chunk length threshold for pipelining */
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-       php_http_option_register(registry, ZEND_STRL("chunk_length_penalty_size"), CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, IS_LONG);
-#endif
-       /* size threshold for pipelining penalty */
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-       php_http_option_register(registry, ZEND_STRL("content_length_penalty_size"), CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, IS_LONG);
-#endif
-       /* pipelining server blacklist */
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("pipelining_server_bl"), CURLMOPT_PIPELINING_SERVER_BL, IS_ARRAY))) {
-               opt->setter = php_http_curlm_option_set_pipelining_bl;
-       }
-#endif
-       /* pipelining host blacklist */
-#if PHP_HTTP_CURL_VERSION(7,30,0)
-       if ((opt = php_http_option_register(registry, ZEND_STRL("pipelining_site_bl"), CURLMOPT_PIPELINING_SITE_BL, IS_ARRAY))) {
-               opt->setter = php_http_curlm_option_set_pipelining_bl;
-       }
-#endif
-       /* events */
-#if PHP_HTTP_HAVE_EVENT
-       if ((opt = php_http_option_register(registry, ZEND_STRL("use_eventloop"), 0, IS_BOOL))) {
-               opt->setter = php_http_curlm_option_set_use_eventloop;
-       }
-#endif
-}
-
-static ZEND_RESULT_CODE php_http_curlm_set_option(php_http_option_t *opt, zval *val, void *userdata)
-{
-       php_http_client_t *client = userdata;
-       php_http_client_curl_t *curl = client->ctx;
-       CURLM *ch = curl->handle;
-       zval *orig = val;
-       CURLMcode rc = CURLM_UNKNOWN_OPTION;
-       ZEND_RESULT_CODE rv = SUCCESS;
-       TSRMLS_FETCH_FROM_CTX(client->ts);
-
-       if (!val) {
-               val = &opt->defval;
-       } else if (opt->type && Z_TYPE_P(val) != opt->type && !(Z_TYPE_P(val) == IS_NULL && opt->type == IS_ARRAY)) {
-               val = php_http_ztyp(opt->type, val);
-       }
-
-       if (opt->setter) {
-               rv = opt->setter(opt, val, client);
-       } else {
-               switch (opt->type) {
-               case IS_BOOL:
-                       if (CURLM_OK != (rc = curl_multi_setopt(ch, opt->option, (long) Z_BVAL_P(val)))) {
-                               rv = FAILURE;
-                       }
-                       break;
-               case IS_LONG:
-                       if (CURLM_OK != (rc = curl_multi_setopt(ch, opt->option, Z_LVAL_P(val)))) {
-                               rv = FAILURE;
-                       }
-                       break;
-               default:
-                       rv = FAILURE;
-                       break;
-               }
-       }
-
-       if (val && val != orig && val != &opt->defval) {
-               zval_ptr_dtor(&val);
-       }
-
-       if (rv != SUCCESS) {
-               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not set option %s (%s)", opt->name.s, curl_easy_strerror(rc));
-       }
-       return rv;
-}
-
-/* client ops */
-
-static ZEND_RESULT_CODE php_http_client_curl_handler_reset(php_http_client_curl_handler_t *curl)
-{
-       CURL *ch = curl->handle;
-       php_http_curle_storage_t *st;
-
-       if ((st = php_http_curle_get_storage(ch))) {
-               if (st->url) {
-                       pefree(st->url, 1);
-                       st->url = NULL;
-               }
-               if (st->cookiestore) {
-                       pefree(st->cookiestore, 1);
-                       st->cookiestore = NULL;
-               }
-               st->errorbuffer[0] = '\0';
-       }
-
-       curl_easy_setopt(ch, CURLOPT_URL, NULL);
-       curl_easy_setopt(ch, CURLOPT_CUSTOMREQUEST, NULL);
-       curl_easy_setopt(ch, CURLOPT_HTTPGET, 1L);
-       curl_easy_setopt(ch, CURLOPT_NOBODY, 0L);
-       /* libcurl < 7.19.6 does not clear auth info with USERPWD set to NULL */
-#if PHP_HTTP_CURL_VERSION(7,19,1)
-       curl_easy_setopt(ch, CURLOPT_PROXYUSERNAME, NULL);
-       curl_easy_setopt(ch, CURLOPT_PROXYPASSWORD, NULL);
-       curl_easy_setopt(ch, CURLOPT_USERNAME, NULL);
-       curl_easy_setopt(ch, CURLOPT_PASSWORD, NULL);
-#endif
-
-#if PHP_HTTP_CURL_VERSION(7,21,3)
-       if (curl->options.resolve) {
-               curl_slist_free_all(curl->options.resolve);
-               curl->options.resolve = NULL;
-       }
-#endif
-       curl->options.retry.count = 0;
-       curl->options.retry.delay = 0;
-       curl->options.redirects = 0;
-       curl->options.encode_cookies = 1;
-
-       if (curl->options.headers) {
-               curl_slist_free_all(curl->options.headers);
-               curl->options.headers = NULL;
-       }
-       if (curl->options.proxyheaders) {
-               curl_slist_free_all(curl->options.proxyheaders);
-               curl->options.proxyheaders = NULL;
-       }
-
-       php_http_buffer_reset(&curl->options.cookies);
-       php_http_buffer_reset(&curl->options.ranges);
-
-       return SUCCESS;
-}
-
-static php_http_client_curl_handler_t *php_http_client_curl_handler_init(php_http_client_t *h, php_resource_factory_t *rf)
-{
-       void *handle;
-       php_http_client_curl_handler_t *handler;
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-       if (!(handle = php_resource_factory_handle_ctor(rf, NULL TSRMLS_CC))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize curl handle");
-               return NULL;
-       }
-
-       handler = ecalloc(1, sizeof(*handler));
-       handler->rf = rf;
-       handler->client = h;
-       handler->handle = handle;
-       handler->response.body = php_http_message_body_init(NULL, NULL TSRMLS_CC);
-       php_http_buffer_init(&handler->response.headers);
-       php_http_buffer_init(&handler->options.cookies);
-       php_http_buffer_init(&handler->options.ranges);
-       zend_hash_init(&handler->options.cache, 0, NULL, ZVAL_PTR_DTOR, 0);
-
-#if defined(ZTS)
-       curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
-#endif
-       curl_easy_setopt(handle, CURLOPT_HEADER, 0L);
-       curl_easy_setopt(handle, CURLOPT_FILETIME, 1L);
-       curl_easy_setopt(handle, CURLOPT_AUTOREFERER, 1L);
-       curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L);
-       curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0L);
-       curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, php_http_curle_header_callback);
-       curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, php_http_curle_body_callback);
-       curl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, php_http_curle_raw_callback);
-       curl_easy_setopt(handle, CURLOPT_READFUNCTION, php_http_curle_read_callback);
-       curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, php_http_curle_seek_callback);
-#if PHP_HTTP_CURL_VERSION(7,32,0)
-       curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, php_http_curle_xferinfo_callback);
-       curl_easy_setopt(handle, CURLOPT_XFERINFODATA, handler);
-#else
-       curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, php_http_curle_progress_callback);
-       curl_easy_setopt(handle, CURLOPT_PROGRESSDATA, handler);
-#endif
-       curl_easy_setopt(handle, CURLOPT_DEBUGDATA, handler);
-       curl_easy_setopt(handle, CURLOPT_WRITEDATA, handler);
-       curl_easy_setopt(handle, CURLOPT_HEADERDATA, handler);
-
-       php_http_client_curl_handler_reset(handler);
-
-       return handler;
-}
-
-
-static ZEND_RESULT_CODE php_http_client_curl_handler_prepare(php_http_client_curl_handler_t *curl, php_http_client_enqueue_t *enqueue)
-{
-       size_t body_size;
-       php_http_message_t *msg = enqueue->request;
-       php_http_curle_storage_t *storage = php_http_curle_get_storage(curl->handle);
-       TSRMLS_FETCH_FROM_CTX(curl->client->ts);
-
-       /* request url */
-       if (!PHP_HTTP_INFO(msg).request.url) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot request empty URL");
-               return FAILURE;
-       }
-       storage->errorbuffer[0] = '\0';
-       if (storage->url) {
-               pefree(storage->url, 1);
-       }
-       php_http_url_to_string(PHP_HTTP_INFO(msg).request.url, &storage->url, NULL, 1);
-       curl_easy_setopt(curl->handle, CURLOPT_URL, storage->url);
-
-       /* apply options */
-       php_http_options_apply(&php_http_curle_options, enqueue->options, curl);
-
-       /* request headers */
-       php_http_message_update_headers(msg);
-       if (zend_hash_num_elements(&msg->hdrs)) {
-               php_http_array_hashkey_t header_key = php_http_array_hashkey_init(0);
-               zval **header_val, *header_cpy;
-               HashPosition pos;
-               php_http_buffer_t header;
-#if !PHP_HTTP_CURL_VERSION(7,23,0)
-               zval **ct = NULL;
-
-               zend_hash_find(&msg->hdrs, ZEND_STRS("Content-Length"), (void *) &ct);
-#endif
-
-               php_http_buffer_init(&header);
-               FOREACH_HASH_KEYVAL(pos, &msg->hdrs, header_key, header_val) {
-                       if (header_key.type == HASH_KEY_IS_STRING) {
-#if !PHP_HTTP_CURL_VERSION(7,23,0)
-                               /* avoid duplicate content-length header */
-                               if (ct && *ct == *header_val) {
-                                       continue;
-                               }
-#endif
-                               header_cpy = php_http_ztyp(IS_STRING, *header_val);
-                               php_http_buffer_appendf(&header, "%s: %s", header_key.str, Z_STRVAL_P(header_cpy));
-                               php_http_buffer_fix(&header);
-                               curl->options.headers = curl_slist_append(curl->options.headers, header.data);
-                               php_http_buffer_reset(&header);
-
-                               zval_ptr_dtor(&header_cpy);
-                       }
-               }
-               php_http_buffer_dtor(&header);
-       }
-       curl_easy_setopt(curl->handle, CURLOPT_HTTPHEADER, curl->options.headers);
-
-       /* attach request body */
-       if ((body_size = php_http_message_body_size(msg->body))) {
-               /* RFC2616, section 4.3 (para. 4) states that »a message-body MUST NOT be included in a request if the
-                * specification of the request method (section 5.1.1) does not allow sending an entity-body in request.«
-                * Following the clause in section 5.1.1 (para. 2) that request methods »MUST be implemented with the
-                * same semantics as those specified in section 9« reveal that not any single defined HTTP/1.1 method
-                * does not allow a request body.
-                */
-               php_stream_rewind(php_http_message_body_stream(msg->body));
-               curl_easy_setopt(curl->handle, CURLOPT_SEEKDATA, msg->body);
-               curl_easy_setopt(curl->handle, CURLOPT_READDATA, msg->body);
-               curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, body_size);
-               curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, body_size);
-               curl_easy_setopt(curl->handle, CURLOPT_POST, 1L);
-       } else {
-               curl_easy_setopt(curl->handle, CURLOPT_SEEKDATA, NULL);
-               curl_easy_setopt(curl->handle, CURLOPT_READDATA, NULL);
-               curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, 0L);
-               curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, 0L);
-       }
-
-       /*
-        * Always use CUSTOMREQUEST, else curl won't send any request body for GET etc.
-        * See e.g. bug #69313.
-        *
-        * Here's what curl does:
-        * - CURLOPT_HTTPGET: ignore request body
-        * - CURLOPT_UPLOAD: set "Expect: 100-continue" header
-        * - CURLOPT_POST: set "Content-Type: application/x-www-form-urlencoded" header
-        * Now select the least bad.
-        *
-        * See also https://tools.ietf.org/html/rfc7231#section-5.1.1
-        */
-       if (PHP_HTTP_INFO(msg).request.method) {
-               switch(php_http_select_str(PHP_HTTP_INFO(msg).request.method, 2, "HEAD", "PUT")) {
-               case 0:
-                       curl_easy_setopt(curl->handle, CURLOPT_NOBODY, 1L);
-                       break;
-               case 1:
-                       curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1L);
-                       break;
-               default:
-                       curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, PHP_HTTP_INFO(msg).request.method);
-               }
-       } else {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot use empty request method");
-               return FAILURE;
-       }
-
-       return SUCCESS;
-}
-
-static void php_http_client_curl_handler_clear(php_http_client_curl_handler_t *handler)
-{
-       curl_easy_setopt(handler->handle, CURLOPT_NOPROGRESS, 1L);
-#if PHP_HTTP_CURL_VERSION(7,32,0)
-       curl_easy_setopt(handler->handle, CURLOPT_XFERINFOFUNCTION, NULL);
-#else
-       curl_easy_setopt(handler->handle, CURLOPT_PROGRESSFUNCTION, NULL);
-#endif
-       curl_easy_setopt(handler->handle, CURLOPT_VERBOSE, 0L);
-       curl_easy_setopt(handler->handle, CURLOPT_DEBUGFUNCTION, NULL);
-}
-
-static void php_http_client_curl_handler_dtor(php_http_client_curl_handler_t *handler)
-{
-       TSRMLS_FETCH_FROM_CTX(handler->client->ts);
-
-       php_http_client_curl_handler_clear(handler);
-
-       php_resource_factory_handle_dtor(handler->rf, handler->handle TSRMLS_CC);
-       php_resource_factory_free(&handler->rf);
-
-       php_http_message_body_free(&handler->response.body);
-       php_http_buffer_dtor(&handler->response.headers);
-       php_http_buffer_dtor(&handler->options.ranges);
-       php_http_buffer_dtor(&handler->options.cookies);
-       zend_hash_destroy(&handler->options.cache);
-
-       if (handler->options.headers) {
-               curl_slist_free_all(handler->options.headers);
-               handler->options.headers = NULL;
-       }
-
-       efree(handler);
-}
-
-static php_http_client_t *php_http_client_curl_init(php_http_client_t *h, void *handle)
-{
-       php_http_client_curl_t *curl;
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-       if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize curl handle");
-               return NULL;
-       }
-
-       curl = ecalloc(1, sizeof(*curl));
-       curl->handle = handle;
-       curl->unfinished = 0;
-       h->ctx = curl;
-
-       return h;
-}
-
-static void php_http_client_curl_dtor(php_http_client_t *h)
-{
-       php_http_client_curl_t *curl = h->ctx;
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-#if PHP_HTTP_HAVE_EVENT
-       if (curl->timeout) {
-               if (event_initialized(curl->timeout) && event_pending(curl->timeout, EV_TIMEOUT, NULL)) {
-                       event_del(curl->timeout);
-               }
-               efree(curl->timeout);
-               curl->timeout = NULL;
-       }
-       if (curl->evbase) {
-               event_base_free(curl->evbase);
-               curl->evbase = NULL;
-       }
-#endif
-       curl->unfinished = 0;
-
-       php_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC);
-
-       efree(curl);
-       h->ctx = NULL;
-}
-
-static void queue_dtor(php_http_client_enqueue_t *e)
-{
-       php_http_client_curl_handler_t *handler = e->opaque;
-
-       if (handler->queue.dtor) {
-               e->opaque = handler->queue.opaque;
-               handler->queue.dtor(e);
-       }
-       php_http_client_curl_handler_dtor(handler);
-}
-
-static php_resource_factory_t *create_rf(php_http_client_t *h, php_http_client_enqueue_t *enqueue TSRMLS_DC)
-{
-       php_persistent_handle_factory_t *pf = NULL;
-       php_resource_factory_t *rf = NULL;
-       php_http_url_t *url = enqueue->request->http.info.request.url;
-
-       if (!url || (!url->host && !url->path)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot request empty URL");
-               return NULL;
-       }
-
-       /* only if the client itself is setup for persistence */
-       if (php_resource_factory_is_persistent(h->rf)) {
-               char *id_str = NULL;
-               size_t id_len;
-               int port = url->port ? url->port : 80;
-               zval **zport;
-
-               if (SUCCESS == zend_hash_find(enqueue->options, ZEND_STRS("port"), (void *) &zport)) {
-                       zval *zcpy = php_http_ztyp(IS_LONG, *zport);
-
-                       if (Z_LVAL_P(zcpy)) {
-                               port = Z_LVAL_P(zcpy);
-                       }
-                       zval_ptr_dtor(&zcpy);
-               }
-
-               id_len = spprintf(&id_str, 0, "%s:%d", STR_PTR(url->host), port);
-               pf = php_persistent_handle_concede(NULL, ZEND_STRL("http\\Client\\Curl\\Request"), id_str, id_len, NULL, NULL TSRMLS_CC);
-               efree(id_str);
-       }
-
-       if (pf) {
-               rf = php_persistent_handle_resource_factory_init(NULL, pf);
-       } else {
-               rf = php_resource_factory_init(NULL, &php_http_curle_resource_factory_ops, NULL, NULL);
-       }
-
-       return rf;
-}
-
-static ZEND_RESULT_CODE php_http_client_curl_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
-{
-       CURLMcode rs;
-       php_http_client_curl_t *curl = h->ctx;
-       php_http_client_curl_handler_t *handler;
-       php_http_client_progress_state_t *progress;
-       php_resource_factory_t *rf;
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-       rf = create_rf(h, enqueue TSRMLS_CC);
-       if (!rf) {
-               return FAILURE;
-       }
-
-       handler = php_http_client_curl_handler_init(h, rf);
-       if (!handler) {
-               return FAILURE;
-       }
-
-       if (SUCCESS != php_http_client_curl_handler_prepare(handler, enqueue)) {
-               php_http_client_curl_handler_dtor(handler);
-               return FAILURE;
-       }
-
-       handler->queue = *enqueue;
-       enqueue->opaque = handler;
-       enqueue->dtor = queue_dtor;
-
-       if (CURLM_OK == (rs = curl_multi_add_handle(curl->handle, handler->handle))) {
-               zend_llist_add_element(&h->requests, enqueue);
-               ++curl->unfinished;
-
-               if (h->callback.progress.func && SUCCESS == php_http_client_getopt(h, PHP_HTTP_CLIENT_OPT_PROGRESS_INFO, enqueue->request, &progress)) {
-                       progress->info = "start";
-                       h->callback.progress.func(h->callback.progress.arg, h, &handler->queue, progress);
-                       progress->started = 1;
-               }
-
-               return SUCCESS;
-       } else {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not enqueue request: %s", curl_multi_strerror(rs));
-               return FAILURE;
-       }
-}
-
-static ZEND_RESULT_CODE php_http_client_curl_dequeue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
-{
-       CURLMcode rs;
-       php_http_client_curl_t *curl = h->ctx;
-       php_http_client_curl_handler_t *handler = enqueue->opaque;
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-       php_http_client_curl_handler_clear(handler);
-       if (CURLM_OK == (rs = curl_multi_remove_handle(curl->handle, handler->handle))) {
-               zend_llist_del_element(&h->requests, handler->handle, (int (*)(void *, void *)) compare_queue);
-               return SUCCESS;
-       } else {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not dequeue request: %s", curl_multi_strerror(rs));
-       }
-
-       return FAILURE;
-}
-
-static void php_http_client_curl_reset(php_http_client_t *h)
-{
-       zend_llist_element *next_el, *this_el;
-
-       for (this_el = h->requests.head; this_el; this_el = next_el) {
-               next_el = this_el->next;
-               php_http_client_curl_dequeue(h, (void *) this_el->data);
-       }
-}
-
-static inline void php_http_client_curl_get_timeout(php_http_client_curl_t *curl, long max_tout, struct timeval *timeout)
-{
-       if ((CURLM_OK == curl_multi_timeout(curl->handle, &max_tout)) && (max_tout > 0)) {
-               timeout->tv_sec = max_tout / 1000;
-               timeout->tv_usec = (max_tout % 1000) * 1000;
-       } else {
-               timeout->tv_sec = 0;
-               timeout->tv_usec = 1000;
-       }
-}
-
-#ifdef PHP_WIN32
-#      define SELECT_ERROR SOCKET_ERROR
-#else
-#      define SELECT_ERROR -1
-#endif
-
-static ZEND_RESULT_CODE php_http_client_curl_wait(php_http_client_t *h, struct timeval *custom_timeout)
-{
-       int MAX;
-       fd_set R, W, E;
-       struct timeval timeout;
-       php_http_client_curl_t *curl = h->ctx;
-
-#if PHP_HTTP_HAVE_EVENT
-       if (curl->useevents) {
-               if (!event_initialized(curl->timeout)) {
-                       event_assign(curl->timeout, curl->evbase, CURL_SOCKET_TIMEOUT, 0, php_http_curlm_timeout_callback, h);
-               } else if (custom_timeout && timerisset(custom_timeout)) {
-                       event_add(curl->timeout, custom_timeout);
-               } else if (!event_pending(curl->timeout, EV_TIMEOUT, NULL)) {
-                       php_http_client_curl_get_timeout(curl, 1000, &timeout);
-                       event_add(curl->timeout, &timeout);
-               }
-
-               event_base_loop(curl->evbase, EVLOOP_ONCE);
-
-               return SUCCESS;
-       }
-#endif
-
-       FD_ZERO(&R);
-       FD_ZERO(&W);
-       FD_ZERO(&E);
-
-       if (CURLM_OK == curl_multi_fdset(curl->handle, &R, &W, &E, &MAX)) {
-               if (custom_timeout && timerisset(custom_timeout)) {
-                       timeout = *custom_timeout;
-               } else {
-                       php_http_client_curl_get_timeout(curl, 1000, &timeout);
-               }
-
-               if (MAX == -1) {
-                       php_http_sleep((double) timeout.tv_sec + (double) (timeout.tv_usec / PHP_HTTP_MCROSEC));
-                       return SUCCESS;
-               } else if (SELECT_ERROR != select(MAX + 1, &R, &W, &E, &timeout)) {
-                       return SUCCESS;
-               }
-       }
-       return FAILURE;
-}
-
-static int php_http_client_curl_once(php_http_client_t *h)
-{
-       php_http_client_curl_t *curl = h->ctx;
-
-#if PHP_HTTP_HAVE_EVENT
-       if (curl->useevents) {
-               event_base_loop(curl->evbase, EVLOOP_NONBLOCK);
-       } else
-#endif
-       while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl->handle, &curl->unfinished));
-
-       php_http_curlm_responsehandler(h);
-
-       return curl->unfinished;
-
-}
-
-static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h)
-{
-#if PHP_HTTP_HAVE_EVENT
-       php_http_client_curl_t *curl = h->ctx;
-#endif
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-#if PHP_HTTP_HAVE_EVENT
-       if (curl->useevents) {
-               php_http_curlm_timeout_callback(CURL_SOCKET_TIMEOUT, /*EV_READ|EV_WRITE*/0, h);
-               do {
-                       int ev_rc = event_base_dispatch(curl->evbase);
-
-#if DBG_EVENTS
-                       fprintf(stderr, "%c", "X.0"[ev_rc+1]);
-#endif
-
-                       if (ev_rc < 0) {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error in event_base_dispatch()");
-                               return FAILURE;
-                       }
-               } while (curl->unfinished && !EG(exception));
-       } else
-#endif
-       {
-               while (php_http_client_curl_once(h) && !EG(exception)) {
-                       if (SUCCESS != php_http_client_curl_wait(h, NULL)) {
-#ifdef PHP_WIN32
-                               /* see http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp */
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "WinSock error: %d", WSAGetLastError());
-#else
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
-#endif
-                               return FAILURE;
-                       }
-               }
-       }
-
-       return SUCCESS;
-}
-
-static ZEND_RESULT_CODE php_http_client_curl_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
-{
-       php_http_client_curl_t *curl = h->ctx;
-
-       switch (opt) {
-               case PHP_HTTP_CLIENT_OPT_CONFIGURATION:
-                       return php_http_options_apply(&php_http_curlm_options, (HashTable *) arg,  h);
-                       break;
-
-               case PHP_HTTP_CLIENT_OPT_ENABLE_PIPELINING:
-                       if (CURLM_OK != curl_multi_setopt(curl->handle, CURLMOPT_PIPELINING, (long) *((zend_bool *) arg))) {
-                               return FAILURE;
-                       }
-                       break;
-
-               case PHP_HTTP_CLIENT_OPT_USE_EVENTS:
-#if PHP_HTTP_HAVE_EVENT
-                       return php_http_curlm_use_eventloop(h, *(zend_bool *) arg);
-                       break;
-#endif
-
-               default:
-                       return FAILURE;
-       }
-       return SUCCESS;
-}
-
-static int apply_available_options(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
-{
-       php_http_option_t *opt = pDest;
-       HashTable *ht;
-       zval *entry;
-       int c;
-
-       ht = va_arg(args, HashTable*);
-
-       MAKE_STD_ZVAL(entry);
-
-       if ((c = zend_hash_num_elements(&opt->suboptions.options))) {
-               array_init_size(entry, c);
-               zend_hash_apply_with_arguments(&opt->suboptions.options TSRMLS_CC, apply_available_options, 1, Z_ARRVAL_P(entry));
-       } else {
-               /* catch deliberate NULL options */
-               if (Z_TYPE(opt->defval) == IS_STRING && !Z_STRVAL(opt->defval)) {
-                       ZVAL_NULL(entry);
-               } else {
-                       ZVAL_COPY_VALUE(entry, &opt->defval);
-                       zval_copy_ctor(entry);
-               }
-       }
-
-       if (hash_key->nKeyLength) {
-               zend_hash_quick_update(ht, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void *) &entry, sizeof(zval *), NULL);
-       } else {
-               zend_hash_index_update(ht, hash_key->h, (void *) &entry, sizeof(zval *), NULL);
-       }
-
-       return ZEND_HASH_APPLY_KEEP;
-}
-
-static ZEND_RESULT_CODE php_http_client_curl_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void **res)
-{
-       php_http_client_enqueue_t *enqueue;
-       TSRMLS_FETCH_FROM_CTX(h->ts);
-
-       switch (opt) {
-       case PHP_HTTP_CLIENT_OPT_PROGRESS_INFO:
-               if ((enqueue = php_http_client_enqueued(h, arg, NULL))) {
-                       php_http_client_curl_handler_t *handler = enqueue->opaque;
-
-                       *((php_http_client_progress_state_t **) res) = &handler->progress;
-                       return SUCCESS;
-               }
-               break;
-
-       case PHP_HTTP_CLIENT_OPT_TRANSFER_INFO:
-               if ((enqueue = php_http_client_enqueued(h, arg, NULL))) {
-                       php_http_client_curl_handler_t *handler = enqueue->opaque;
-
-                       php_http_curle_get_info(handler->handle, *(HashTable **) res);
-                       return SUCCESS;
-               }
-               break;
-
-       case PHP_HTTP_CLIENT_OPT_AVAILABLE_OPTIONS:
-               zend_hash_apply_with_arguments(&php_http_curle_options.options TSRMLS_CC, apply_available_options, 1, *(HashTable **) res);
-               break;
-
-       case PHP_HTTP_CLIENT_OPT_AVAILABLE_CONFIGURATION:
-               zend_hash_apply_with_arguments(&php_http_curlm_options.options TSRMLS_CC, apply_available_options, 1, *(HashTable **) res);
-               break;
-
-       default:
-               break;
-       }
-
-       return FAILURE;
-}
-
-static php_http_client_ops_t php_http_client_curl_ops = {
-       &php_http_curlm_resource_factory_ops,
-       php_http_client_curl_init,
-       NULL /* copy */,
-       php_http_client_curl_dtor,
-       php_http_client_curl_reset,
-       php_http_client_curl_exec,
-       php_http_client_curl_wait,
-       php_http_client_curl_once,
-       php_http_client_curl_enqueue,
-       php_http_client_curl_dequeue,
-       php_http_client_curl_setopt,
-       php_http_client_curl_getopt
-};
-
-php_http_client_ops_t *php_http_client_curl_get_ops(void)
-{
-       return &php_http_client_curl_ops;
-}
-
-PHP_MINIT_FUNCTION(http_client_curl)
-{
-       php_http_options_t *options;
-       php_http_client_driver_t driver = {
-               ZEND_STRL("curl"),
-               &php_http_client_curl_ops
-       };
-
-       if (SUCCESS != php_http_client_driver_add(&driver)) {
-               return FAILURE;
-       }
-
-       if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http\\Client\\Curl"), &php_http_curlm_resource_factory_ops, NULL, NULL TSRMLS_CC)) {
-               return FAILURE;
-       }
-       if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http\\Client\\Curl\\Request"), &php_http_curle_resource_factory_ops, NULL, NULL TSRMLS_CC)) {
-               return FAILURE;
-       }
-
-       if ((options = php_http_options_init(&php_http_curle_options, 1))) {
-               options->getter = php_http_curle_get_option;
-               options->setter = php_http_curle_set_option;
-
-               php_http_curle_options_init(options TSRMLS_CC);
-       }
-       if ((options = php_http_options_init(&php_http_curlm_options, 1))) {
-               options->getter = php_http_option_get;
-               options->setter = php_http_curlm_set_option;
-
-               php_http_curlm_options_init(options TSRMLS_CC);
-       }
-
-       /*
-       * HTTP Protocol Version Constants
-       */
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "HTTP_VERSION_1_0", CURL_HTTP_VERSION_1_0, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "HTTP_VERSION_1_1", CURL_HTTP_VERSION_1_1, CONST_CS|CONST_PERSISTENT);
-#if PHP_HTTP_CURL_VERSION(7,33,0)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "HTTP_VERSION_2_0", CURL_HTTP_VERSION_2_0, CONST_CS|CONST_PERSISTENT);
-#endif
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "HTTP_VERSION_ANY", CURL_HTTP_VERSION_NONE, CONST_CS|CONST_PERSISTENT);
-
-       /*
-       * SSL Version Constants
-       */
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_TLSv1", CURL_SSLVERSION_TLSv1, CONST_CS|CONST_PERSISTENT);
-#if PHP_HTTP_CURL_VERSION(7,34,0)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_TLSv1_0", CURL_SSLVERSION_TLSv1_0, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_TLSv1_1", CURL_SSLVERSION_TLSv1_1, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_TLSv1_2", CURL_SSLVERSION_TLSv1_2, CONST_CS|CONST_PERSISTENT);
-#endif
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_SSLv2", CURL_SSLVERSION_SSLv2, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_SSLv3", CURL_SSLVERSION_SSLv3, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_ANY", CURL_SSLVERSION_DEFAULT, CONST_CS|CONST_PERSISTENT);
-#if PHP_HTTP_CURL_VERSION(7,21,4) && defined(PHP_HTTP_CURL_TLSAUTH_SRP)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "TLSAUTH_SRP", CURL_TLSAUTH_SRP, CONST_CS|CONST_PERSISTENT);
-#endif
-
-       /*
-       * DNS IPvX resolving
-       */
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "IPRESOLVE_V4", CURL_IPRESOLVE_V4, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "IPRESOLVE_V6", CURL_IPRESOLVE_V6, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "IPRESOLVE_ANY", CURL_IPRESOLVE_WHATEVER, CONST_CS|CONST_PERSISTENT);
-
-       /*
-       * Auth Constants
-       */
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_BASIC", CURLAUTH_BASIC, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_DIGEST", CURLAUTH_DIGEST, CONST_CS|CONST_PERSISTENT);
-#if PHP_HTTP_CURL_VERSION(7,19,3)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_DIGEST_IE", CURLAUTH_DIGEST_IE, CONST_CS|CONST_PERSISTENT);
-#endif
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_NTLM", CURLAUTH_NTLM, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_GSSNEG", CURLAUTH_GSSNEGOTIATE, CONST_CS|CONST_PERSISTENT);
-#if PHP_HTTP_CURL_VERSION(7,38,0)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_SPNEGO", CURLAUTH_NEGOTIATE, CONST_CS|CONST_PERSISTENT);
-#endif
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_ANY", CURLAUTH_ANY, CONST_CS|CONST_PERSISTENT);
-
-       /*
-       * Proxy Type Constants
-       */
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "PROXY_SOCKS4", CURLPROXY_SOCKS4, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "PROXY_SOCKS4A", CURLPROXY_SOCKS5, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "PROXY_SOCKS5_HOSTNAME", CURLPROXY_SOCKS5, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "PROXY_SOCKS5", CURLPROXY_SOCKS5, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "PROXY_HTTP", CURLPROXY_HTTP, CONST_CS|CONST_PERSISTENT);
-#if PHP_HTTP_CURL_VERSION(7,19,4)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "PROXY_HTTP_1_0", CURLPROXY_HTTP_1_0, CONST_CS|CONST_PERSISTENT);
-#endif
-
-       /*
-       * Post Redirection Constants
-       */
-#if PHP_HTTP_CURL_VERSION(7,19,1)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_301", CURL_REDIR_POST_301, CONST_CS|CONST_PERSISTENT);
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_302", CURL_REDIR_POST_302, CONST_CS|CONST_PERSISTENT);
-#if PHP_HTTP_CURL_VERSION(7,26,0)
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_303", CURL_REDIR_POST_303, CONST_CS|CONST_PERSISTENT);
-#endif
-       REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "POSTREDIR_ALL", CURL_REDIR_POST_ALL, CONST_CS|CONST_PERSISTENT);
-#endif
-
-       return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(http_client_curl)
-{
-       php_persistent_handle_cleanup(ZEND_STRL("http\\Client\\Curl"), NULL, 0 TSRMLS_CC);
-       php_persistent_handle_cleanup(ZEND_STRL("http\\Client\\Curl\\Request"), NULL, 0 TSRMLS_CC);
-
-       php_http_options_dtor(&php_http_curle_options);
-       php_http_options_dtor(&php_http_curlm_options);
-
-       return SUCCESS;
-}
-
-#endif /* PHP_HTTP_HAVE_CURL */
-
-/*
- * 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
- */
diff --git a/php_http_client_curl.h b/php_http_client_curl.h
deleted file mode 100644 (file)
index c82a09c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_CLIENT_CURL_H
-#define PHP_HTTP_CLIENT_CURL_H
-
-#if PHP_HTTP_HAVE_CURL
-
-PHP_MINIT_FUNCTION(http_client_curl);
-PHP_MSHUTDOWN_FUNCTION(http_client_curl);
-#endif /* PHP_HTTP_HAVE_CURL */
-
-#endif /* PHP_HTTP_CLIENT_CURL_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
- */
diff --git a/php_http_client_request.c b/php_http_client_request.c
deleted file mode 100644 (file)
index 0e40cc5..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-void php_http_client_options_set_subr(zval *this_ptr, char *key, size_t len, zval *opts, int overwrite TSRMLS_DC);
-void php_http_client_options_set(zval *this_ptr, zval *opts TSRMLS_DC);
-void php_http_client_options_get_subr(zval *this_ptr, char *key, size_t len, zval *return_value TSRMLS_DC);
-
-#define PHP_HTTP_CLIENT_REQUEST_OBJECT_INIT(obj) \
-       do { \
-               if (!obj->message) { \
-                       obj->message = php_http_message_init(NULL, PHP_HTTP_REQUEST, NULL TSRMLS_CC); \
-               } \
-       } while(0)
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest___construct, 0, 0, 0)
-       ZEND_ARG_INFO(0, method)
-       ZEND_ARG_INFO(0, url)
-       ZEND_ARG_ARRAY_INFO(0, headers, 1)
-       ZEND_ARG_OBJ_INFO(0, body, http\\Message\\Body, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, __construct)
-{
-       char *meth_str = NULL;
-       int meth_len = 0;
-       zval *zheaders = NULL, *zbody = NULL, *zurl = NULL;
-       php_http_message_object_t *obj;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!z!a!O!", &meth_str, &meth_len, &zurl, &zheaders, &zbody, php_http_message_body_class_entry), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       if (obj->message) {
-               php_http_message_set_type(obj->message, PHP_HTTP_REQUEST);
-       } else {
-               obj->message = php_http_message_init(NULL, PHP_HTTP_REQUEST, NULL TSRMLS_CC);
-       }
-
-       if (zbody) {
-               php_http_expect(SUCCESS == php_http_message_object_set_body(obj, zbody TSRMLS_CC), unexpected_val, return);
-       }
-       if (meth_str && meth_len) {
-               PHP_HTTP_INFO(obj->message).request.method = estrndup(meth_str, meth_len);
-       }
-       if (zurl) {
-               PHP_HTTP_INFO(obj->message).request.url = php_http_url_from_zval(zurl, ~0 TSRMLS_CC);
-       }
-       if (zheaders) {
-               array_copy(Z_ARRVAL_P(zheaders), &obj->message->hdrs);
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_setContentType, 0, 0, 1)
-       ZEND_ARG_INFO(0, content_type)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, setContentType)
-{
-       char *ct_str;
-       int ct_len;
-       php_http_message_object_t *obj;
-       zval *zct;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ct_str, &ct_len), invalid_arg, return);
-
-       if (ct_len && !strchr(ct_str, '/')) {
-               php_http_throw(unexpected_val, "Content type \"%s\" does not seem to contain a primary and a secondary part", ct_str);
-               return;
-       }
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       PHP_HTTP_CLIENT_REQUEST_OBJECT_INIT(obj);
-
-       MAKE_STD_ZVAL(zct);
-       ZVAL_STRINGL(zct, ct_str, ct_len, 1);
-       zend_hash_update(&obj->message->hdrs, "Content-Type", sizeof("Content-Type"), (void *) &zct, sizeof(void *), NULL);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_getContentType, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, getContentType)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-               zval *zct;
-
-               PHP_HTTP_CLIENT_REQUEST_OBJECT_INIT(obj);
-
-               php_http_message_update_headers(obj->message);
-               zct = php_http_message_header(obj->message, ZEND_STRL("Content-Type"), 1);
-               if (zct) {
-                       RETURN_ZVAL(zct, 0, 1);
-               }
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_setQuery, 0, 0, 0)
-       ZEND_ARG_INFO(0, query_data)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, setQuery)
-{
-       zval *qdata = NULL;
-       php_http_message_object_t *obj;
-       php_http_url_t *old_url = NULL, new_url = {NULL};
-       char empty[] = "";
-       unsigned flags = PHP_HTTP_URL_REPLACE;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!", &qdata), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       PHP_HTTP_CLIENT_REQUEST_OBJECT_INIT(obj);
-
-       if (qdata) {
-               zval arr, str;
-
-               INIT_PZVAL(&arr);
-               array_init(&arr);
-               INIT_PZVAL(&str);
-               ZVAL_NULL(&str);
-
-               php_http_expect(SUCCESS == php_http_querystring_update(&arr, qdata, &str TSRMLS_CC), bad_querystring,
-                               zval_dtor(&arr);
-                               return;
-               );
-               new_url.query = Z_STRVAL(str);
-               zval_dtor(&arr);
-       } else {
-               flags = PHP_HTTP_URL_STRIP_QUERY;
-       }
-
-       if (obj->message->http.info.request.url) {
-               old_url = obj->message->http.info.request.url;
-       }
-
-       obj->message->http.info.request.url = php_http_url_mod(old_url, &new_url, flags TSRMLS_CC);
-
-       if (old_url) {
-               php_http_url_free(&old_url);
-       }
-       if (new_url.query != &empty[0]) {
-               PTR_FREE(new_url.query);
-       }
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_getQuery, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, getQuery)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-               PHP_HTTP_CLIENT_REQUEST_OBJECT_INIT(obj);
-
-               if (obj->message->http.info.request.url && obj->message->http.info.request.url->query) {
-                       RETVAL_STRING(obj->message->http.info.request.url->query, 1);
-               }
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_addQuery, 0, 0, 1)
-       ZEND_ARG_INFO(0, query_data)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, addQuery)
-{
-       zval *qdata, arr, str;
-       php_http_message_object_t *obj;
-       php_http_url_t *old_url = NULL, new_url = {NULL};
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &qdata), invalid_arg, return);
-
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       PHP_HTTP_CLIENT_REQUEST_OBJECT_INIT(obj);
-
-       INIT_PZVAL(&arr);
-       array_init(&arr);
-       INIT_PZVAL(&str);
-       ZVAL_NULL(&str);
-
-       php_http_expect(SUCCESS == php_http_querystring_update(&arr, qdata, &str TSRMLS_CC), bad_querystring,
-                       zval_dtor(&arr);
-                       return;
-       );
-       new_url.query = Z_STRVAL(str);
-       zval_dtor(&arr);
-
-       if (obj->message->http.info.request.url) {
-               old_url = obj->message->http.info.request.url;
-       }
-
-       obj->message->http.info.request.url = php_http_url_mod(old_url, &new_url, PHP_HTTP_URL_JOIN_QUERY TSRMLS_CC);
-
-       if (old_url) {
-               php_http_url_free(&old_url);
-       }
-       PTR_FREE(new_url.query);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_setOptions, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, options, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, setOptions)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set(getThis(), opts TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_getOptions, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, getOptions)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               zval *zoptions = zend_read_property(php_http_client_request_class_entry, getThis(), ZEND_STRL("options"), 0 TSRMLS_CC);
-               RETURN_ZVAL(zoptions, 1, 0);
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_setSslOptions, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, ssl_options, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, setSslOptions)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts, 1 TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_addSslOptions, 0, 0, 0)
-       ZEND_ARG_ARRAY_INFO(0, ssl_options, 1)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, addSslOptions)
-{
-       zval *opts = NULL;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts), invalid_arg, return);
-
-       php_http_client_options_set_subr(getThis(), ZEND_STRS("ssl"), opts, 0 TSRMLS_CC);
-
-       RETVAL_ZVAL(getThis(), 1, 0);
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientRequest_getSslOptions, 0, 0, 0)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientRequest, getSslOptions)
-{
-       if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_client_options_get_subr(getThis(), ZEND_STRS("ssl"), return_value TSRMLS_CC);
-       }
-}
-
-static zend_function_entry php_http_client_request_methods[] = {
-       PHP_ME(HttpClientRequest, __construct,    ai_HttpClientRequest___construct,    ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
-       PHP_ME(HttpClientRequest, setContentType, ai_HttpClientRequest_setContentType, ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, getContentType, ai_HttpClientRequest_getContentType, ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, setQuery,       ai_HttpClientRequest_setQuery,       ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, getQuery,       ai_HttpClientRequest_getQuery,       ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, addQuery,       ai_HttpClientRequest_addQuery,       ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, setOptions,     ai_HttpClientRequest_setOptions,     ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, getOptions,     ai_HttpClientRequest_getOptions,     ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, setSslOptions,  ai_HttpClientRequest_setSslOptions,  ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, getSslOptions,  ai_HttpClientRequest_getSslOptions,  ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientRequest, addSslOptions,  ai_HttpClientRequest_addSslOptions,  ZEND_ACC_PUBLIC)
-       EMPTY_FUNCTION_ENTRY
-};
-
-zend_class_entry *php_http_client_request_class_entry;
-
-PHP_MINIT_FUNCTION(http_client_request)
-{
-       zend_class_entry ce = {0};
-
-       INIT_NS_CLASS_ENTRY(ce, "http\\Client", "Request", php_http_client_request_methods);
-       php_http_client_request_class_entry = zend_register_internal_class_ex(&ce, php_http_message_class_entry, NULL TSRMLS_CC);
-
-       zend_declare_property_null(php_http_client_request_class_entry, ZEND_STRL("options"), ZEND_ACC_PROTECTED TSRMLS_CC);
-
-       return SUCCESS;
-}
-
-/*
- * 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
- */
-
diff --git a/php_http_client_request.h b/php_http_client_request.h
deleted file mode 100644 (file)
index 474114b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_CLIENT_REQUEST_H
-#define PHP_HTTP_CLIENT_REQUEST_H
-
-PHP_HTTP_API zend_class_entry *php_http_client_request_class_entry;
-PHP_MINIT_FUNCTION(http_client_request);
-
-#endif /* PHP_HTTP_CLIENT_REQUEST_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
- */
diff --git a/php_http_client_response.c b/php_http_client_response.c
deleted file mode 100644 (file)
index 8d512ec..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientResponse_getCookies, 0, 0, 0)
-       ZEND_ARG_INFO(0, flags)
-       ZEND_ARG_INFO(0, allowed_extras)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientResponse, getCookies)
-{
-       long flags = 0;
-       zval *allowed_extras_array = NULL;
-       int i = 0;
-       char **allowed_extras = NULL;
-       zval *header = NULL, **entry = NULL;
-       HashPosition pos;
-       php_http_message_object_t *msg;
-
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|la!", &flags, &allowed_extras_array)) {
-               return;
-       }
-
-       msg = zend_object_store_get_object(getThis() TSRMLS_CC);
-       array_init(return_value);
-
-       if (allowed_extras_array) {
-               allowed_extras = ecalloc(zend_hash_num_elements(Z_ARRVAL_P(allowed_extras_array)) + 1, sizeof(char *));
-               FOREACH_VAL(pos, allowed_extras_array, entry) {
-                       zval *data = php_http_ztyp(IS_STRING, *entry);
-                       allowed_extras[i++] = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
-                       zval_ptr_dtor(&data);
-               }
-       }
-
-       if ((header = php_http_message_header(msg->message, ZEND_STRL("Set-Cookie"), 0))) {
-               php_http_cookie_list_t *list;
-
-               if (Z_TYPE_P(header) == IS_ARRAY) {
-                       zval **single_header;
-
-                       FOREACH_VAL(pos, header, single_header) {
-                               zval *data = php_http_ztyp(IS_STRING, *single_header);
-
-                               if ((list = php_http_cookie_list_parse(NULL, Z_STRVAL_P(data), Z_STRLEN_P(data), flags, allowed_extras TSRMLS_CC))) {
-                                       zval *cookie;
-
-                                       MAKE_STD_ZVAL(cookie);
-                                       ZVAL_OBJVAL(cookie, php_http_cookie_object_new_ex(php_http_cookie_class_entry, list, NULL TSRMLS_CC), 0);
-                                       add_next_index_zval(return_value, cookie);
-                               }
-                               zval_ptr_dtor(&data);
-                       }
-               } else {
-                       zval *data = php_http_ztyp(IS_STRING, header);
-                       if ((list = php_http_cookie_list_parse(NULL, Z_STRVAL_P(data), Z_STRLEN_P(data), flags, allowed_extras TSRMLS_CC))) {
-                               zval *cookie;
-
-                               MAKE_STD_ZVAL(cookie);
-                               ZVAL_OBJVAL(cookie, php_http_cookie_object_new_ex(php_http_cookie_class_entry, list, NULL TSRMLS_CC), 0);
-                               add_next_index_zval(return_value, cookie);
-                       }
-                       zval_ptr_dtor(&data);
-               }
-               zval_ptr_dtor(&header);
-       }
-
-       if (allowed_extras) {
-               for (i = 0; allowed_extras[i]; ++i) {
-                       efree(allowed_extras[i]);
-               }
-               efree(allowed_extras);
-       }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientResponse_getTransferInfo, 0, 0, 0)
-       ZEND_ARG_INFO(0, element)
-ZEND_END_ARG_INFO();
-static PHP_METHOD(HttpClientResponse, getTransferInfo)
-{
-       char *info_name = NULL;
-       int info_len = 0;
-       zval *info;
-
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &info_name, &info_len), invalid_arg, return);
-
-       info = zend_read_property(php_http_client_response_class_entry, getThis(), ZEND_STRL("transferInfo"), 0 TSRMLS_CC);
-
-       /* request completed? */
-       if (Z_TYPE_P(info) != IS_OBJECT) {
-               php_http_throw(bad_method_call, "Incomplete state", NULL);
-               return;
-       }
-
-       if (info_len && info_name) {
-               info = zend_read_property(NULL, info, php_http_pretty_key(info_name, info_len, 0, 0), info_len, 0 TSRMLS_CC);
-
-               if (!info) {
-                       php_http_throw(unexpected_val, "Could not find transfer info with name '%s'", info_name);
-                       return;
-               }
-       }
-
-       RETURN_ZVAL(info, 1, 0);
-}
-
-static zend_function_entry php_http_client_response_methods[] = {
-       PHP_ME(HttpClientResponse, getCookies,      ai_HttpClientResponse_getCookies,      ZEND_ACC_PUBLIC)
-       PHP_ME(HttpClientResponse, getTransferInfo, ai_HttpClientResponse_getTransferInfo, ZEND_ACC_PUBLIC)
-       EMPTY_FUNCTION_ENTRY
-};
-
-zend_class_entry *php_http_client_response_class_entry;
-
-PHP_MINIT_FUNCTION(http_client_response)
-{
-       zend_class_entry ce = {0};
-
-       INIT_NS_CLASS_ENTRY(ce, "http\\Client", "Response", php_http_client_response_methods);
-       php_http_client_response_class_entry = zend_register_internal_class_ex(&ce, php_http_message_class_entry, NULL TSRMLS_CC);
-       zend_declare_property_null(php_http_client_response_class_entry, ZEND_STRL("transferInfo"), ZEND_ACC_PROTECTED TSRMLS_CC);
-
-       return SUCCESS;
-}
-
-/*
- * 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
- */
-
diff --git a/php_http_client_response.h b/php_http_client_response.h
deleted file mode 100644 (file)
index 15d004e..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#ifndef PHP_HTTP_CLIENT_RESPONSE_H
-#define PHP_HTTP_CLIENT_RESPONSE_H
-
-PHP_HTTP_API zend_class_entry *php_http_client_response_class_entry;
-PHP_MINIT_FUNCTION(http_client_response);
-
-#endif /* PHP_HTTP_CLIENT_RESPONSE_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
- */
diff --git a/php_http_cookie.c b/php_http_cookie.c
deleted file mode 100644 (file)
index 354dfa6..0000000
+++ /dev/null
@@ -1,1038 +0,0 @@
-/*
-    +--------------------------------------------------------------------+
-    | PECL :: http                                                       |
-    +--------------------------------------------------------------------+
-    | 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) 2004-2014, Michael Wallner <mike@php.net>            |
-    +--------------------------------------------------------------------+
-*/
-
-#include "php_http_api.h"
-
-php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list TSRMLS_DC)
-{
-       if (!list) {
-               list = emalloc(sizeof(*list));
-       }
-       
-       zend_hash_init(&list->cookies, 0, NULL, ZVAL_PTR_DTOR, 0);
-       zend_hash_init(&list->extras, 0, NULL, ZVAL_PTR_DTOR, 0);
-       
-       list->path = NULL;
-       list->domain = NULL;
-       list->expires = -1;
-       list->max_age = -1;
-       list->flags = 0;
-       
-       TSRMLS_SET_CTX(list->ts);
-
-       return list;
-}
-
-php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_list_t *from, php_http_cookie_list_t *to)
-{
-       TSRMLS_FETCH_FROM_CTX(from->ts);
-
-       to = php_http_cookie_list_init(to TSRMLS_CC);
-
-       array_copy(&from->cookies, &to->cookies);
-       array_copy(&from->extras, &to->extras);
-
-       PTR_SET(to->path, from->path ? estrdup(from->path) : NULL);
-       PTR_SET(to->domain, from->domain ? estrdup(from->domain) : NULL);
-       to->expires = from->expires;
-       to->max_age = from->max_age;
-       to->flags = from->flags;
-
-       return to;
-}
-
-void php_http_cookie_list_dtor(php_http_cookie_list_t *list)
-{
-       if (list) {
-               zend_hash_destroy(&list->cookies);
-               zend_hash_destroy(&list->extras);
-       
-               PTR_SET(list->path, NULL);
-               PTR_SET(list->domain, NULL);
-       }
-}
-
-
-
-void php_http_cookie_list_free(php_http_cookie_list_t **list)
-{
-       if (*list) {
-               php_http_cookie_list_dtor(*list);
-               efree(*list);
-               *list = NULL;
-       }
-}
-
-const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, zval **zcookie)
-{
-       zval **cookie;
-       if ((SUCCESS != zend_symtable_find(&list->cookies, name, name_len + 1, (void *) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) {
-               return NULL;
-       }
-       if (zcookie) {
-               *zcookie = *cookie;
-       }
-       return Z_STRVAL_PP(cookie);
-}
-
-const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, zval **zextra)
-{
-       zval **extra;
-
-       if ((SUCCESS != zend_symtable_find(&list->extras, name, name_len + 1, (void *) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) {
-               return NULL;
-       }
-       if (zextra) {
-               *zextra = *extra;
-       }
-       return Z_STRVAL_PP(extra);
-}
-
-void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len)
-{
-       zval *cookie_value;
-
-       MAKE_STD_ZVAL(cookie_value);
-       ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0);
-       zend_symtable_update(&list->cookies, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
-}
-
-void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len)
-{
-       zval *cookie_value;
-
-       MAKE_STD_ZVAL(cookie_value);
-       ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0);
-       zend_symtable_update(&list->extras, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
-}
-
-#define _KEY_IS(s) (key->len == sizeof(s) && !strncasecmp(key->str, (s), key->len))
-static void add_entry(php_http_cookie_list_t *list, char **allowed_extras, long flags, php_http_array_hashkey_t *key, zval *val)
-{
-       zval *arg = php_http_zsep(1, IS_STRING, val);
-
-       if (!(flags & PHP_HTTP_COOKIE_PARSE_RAW)) {
-               Z_STRLEN_P(arg) = php_raw_url_decode(Z_STRVAL_P(arg), Z_STRLEN_P(arg));
-       }
-
-       if _KEY_IS("path") {
-               PTR_SET(list->path, estrndup(Z_STRVAL_P(arg), Z_STRLEN_P(arg)));
-       } else if _KEY_IS("domain") {
-               PTR_SET(list->domain, estrndup(Z_STRVAL_P(arg), Z_STRLEN_P(arg)));
-       } else if _KEY_IS("expires") {
-               char *date = estrndup(Z_STRVAL_P(arg), Z_STRLEN_P(arg));
-               list->expires = php_parse_date(date, NULL);
-               efree(date);
-       } else if _KEY_IS("max-age") {
-               list->max_age = strtol(Z_STRVAL_P(arg), NULL, 10);
-       } else if _KEY_IS("secure") {
-               list->flags |= PHP_HTTP_COOKIE_SECURE;
-       } else if _KEY_IS("httpOnly") {
-               list->flags |= PHP_HTTP_COOKIE_HTTPONLY;
-       } else {
-               /* check for extra */
-               if (allowed_extras) {
-                       char **ae = allowed_extras;
-
-                       php_http_array_hashkey_stringify(key);
-                       for (; *ae; ++ae) {
-                               if (!strncasecmp(key->str, *ae, key->len)) {
-                                       if (key->type == HASH_KEY_IS_LONG) {
-                                               zend_hash_index_update(&list->extras, key->num, (void *) &arg, sizeof(zval *), NULL);
-                                       } else {
-                                               zend_hash_update(&list->extras, key->str, key->len, (void *) &arg, sizeof(zval *), NULL);
-                                       }
-                                       php_http_array_hashkey_stringfree(key);
-                                       return;
-                               }
-                       }
-                       php_http_array_hashkey_stringfree(key);
-               }
-
-               /* cookie */
-               if (key->type == HASH_KEY_IS_LONG) {
-                       zend_hash_index_update(&list->cookies, key->num, (void *) &arg, sizeof(zval *), NULL);
-               } else {
-                       zend_hash_update(&list->cookies, key->str, key->len, (void *) &arg, sizeof(zval *), NULL);
-               }
-               return;
-       }
-       zval_ptr_dtor(&arg);
-}
-
-php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *str, size_t len, long flags, char **allowed_extras TSRMLS_DC)
-{
-       php_http_params_opts_t opts;
-       HashTable params;
-       HashPosition pos1, pos2;
-       php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
-       zval **param, **val, **args, **arg;
-
-       php_http_params_opts_default_get(&opts);
-       opts.input.str = estrndup(str, len);
-       opts.input.len = len;
-       opts.param = NULL;
-       zend_hash_init(&params, 10, NULL, ZVAL_PTR_DTOR, 0);
-       php_http_params_parse(&params, &opts TSRMLS_CC);
-       efree(opts.input.str);
-
-       list = php_http_cookie_list_init(list TSRMLS_CC);
-       FOREACH_HASH_KEYVAL(pos1, &params, key, param) {
-               if (Z_TYPE_PP(param) == IS_ARRAY) {
-                       if (SUCCESS == zend_hash_find(Z_ARRVAL_PP(param), ZEND_STRS("value"), (void *) &val)) {
-                               add_entry(list, NULL, flags, &key, *val);
-                       }
-                       if (SUCCESS == zend_hash_find(Z_ARRVAL_PP(param), ZEND_STRS("arguments"), (void *) &args) && Z_TYPE_PP(args) == IS_ARRAY) {
-                               FOREACH_KEYVAL(pos2, *args, key, arg) {
-                                       add_entry(list, allowed_extras, flags, &key, *arg);
-                               }
-                       }
-               }
-       }
-       zend_hash_destroy(&params);
-
-       return list;
-}
-
-void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct)
-{
-       zval array, *cookies, *extras;
-       TSRMLS_FETCH_FROM_CTX(list->ts);
-       
-       INIT_PZVAL_ARRAY(&array, HASH_OF(strct));
-       
-       MAKE_STD_ZVAL(cookies);
-       array_init(cookies);
-       zend_hash_copy(Z_ARRVAL_P(cookies), &list->cookies, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-       add_assoc_zval(&array, "cookies", cookies);
-       
-       MAKE_STD_ZVAL(extras);
-       array_init(extras);
-       zend_hash_copy(Z_ARRVAL_P(extras), &list->extras, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-       add_assoc_zval(&array, "extras", extras);
-       
-       add_assoc_long(&array, "flags", list->flags);