From: Michael Wallner Date: Fri, 7 Aug 2015 09:36:04 +0000 (+0200) Subject: Merge branch 'master' into phpng X-Git-Tag: RELEASE_3_0_0_RC1~36 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=1f37d09e4c7f55cf6f2c3c10ea3ec2424a482671;hp=f00dec5b0217c81cf9d71d96103106fdaf2ab310 Merge branch 'master' into phpng Conflicts: php_http_client.c php_http_client_curl.c php_http_env_request.c php_http_env_response.c php_http_header_parser.c --- diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e53f88c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "travis-pecl"] + path = travis/pecl + url = https://github.com/m6w6/travis-pecl.git + branch = master diff --git a/.travis.yml b/.travis.yml index 7dc1227..9ac2777 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,52 @@ -language: php +# autogenerated file; do not edit +language: c -php: - - 5.3 - - 5.4 +addons: + apt: + packages: + - php5-cli + - php-pear + - libcurl4-openssl-dev + - zlib1g-dev + - libidn11-dev + - libevent-dev -before_script: phpize +env: + - PHP=5.4 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.4 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.4 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.4 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes + - PHP=5.4 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.4 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.4 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.4 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.5 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=5.6 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes -script: ./configure && make && NO_INTERACTION=1 REPORT_EXIT_STATUS=1 TEST_PHP_DETAILED=1 make test +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/README.md b/README.md new file mode 100644 index 0000000..09dcd90 --- /dev/null +++ b/README.md @@ -0,0 +1,121 @@ +# pecl/http v2 + +[![Build Status](https://travis-ci.org/m6w6/ext-http.svg?branch=master)](https://travis-ci.org/m6w6/ext-http) + +## About: + +Extended HTTP support. Again. + +* Introduces the http namespace. +* PHP stream based message bodies. +* Encapsulated env request/response. +* Modular client support. + +## Installation: + +This extension is hosted at [PECL](http://pecl.php.net) and can be installed with [PEAR](http://pear.php.net)'s pecl command: + + # pecl install pecl_http + +## Dependencies: + +pecl/http depends on a number of system libraries and PHP extensions for special features. + +#### Required system libraries: + +The following system libraries are required to build this extension: + +##### zlib +Provides gzip/zlib/deflate encoding. +Minimum version: 1.2.0.4 +Install on Debian: `apt-get install zlib1g-dev` + + +#### Optional system libraries: + +The following system libraries are optional and provide additional features: + +##### libidn +Provides IDNA support in URLs. +Minimum version: none +Install on Debian: `apt-get install libidn11-dev` + +##### libidn2 +Provides IDNA support in URLs (fallback if libidn is not available). +Minimum version: none +Install on Debian: `apt-get install libidn2-0-dev` + +##### libicu +Provides IDNA support in URLs (fallback if libidn is not available). +Minimum version: none +Install on Debian: `apt-get install libicu-dev` + +##### 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 diff --git a/config9.m4 b/config9.m4 index b82a3a7..c38107c 100644 --- a/config9.m4 +++ b/config9.m4 @@ -93,6 +93,34 @@ if test "$PHP_HTTP" != "no"; then fi ]) + dnl + dnl HTTP_CURL_SSL_LIB_CHECK(ssllib[, code-if-yes[, code-if-not]) + dnl + AC_DEFUN([HTTP_CURL_SSL_LIB_CHECK], [ + AC_MSG_CHECKING([for $1 support in libcurl]) + AC_TRY_RUN([ + #include + int main(int argc, char *argv[]) { + curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); + if (data && data->ssl_version && *data->ssl_version) { + const char *ptr = data->ssl_version; + while(*ptr == ' ') ++ptr; + return strncasecmp(ptr, "$1", sizeof("$1")-1); + } + return 1; + } + ], [ + AC_MSG_RESULT([yes]) + $2 + ], [ + AC_MSG_RESULT([no]) + $3 + ], [ + AC_MSG_RESULT([no]) + $3 + ]) + ]) + dnl ---- dnl STDC @@ -288,58 +316,33 @@ dnl ---- AC_MSG_RESULT([yes]) AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ]) - AC_MSG_CHECKING([for openssl support in libcurl]) - AC_TRY_RUN([ - #include - int main(int argc, char *argv[]) { - curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); - if (data && data->ssl_version && *data->ssl_version) { - const char *ptr = data->ssl_version; - while(*ptr == ' ') ++ptr; - return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1); - } - return 1; - } - ], [ - AC_MSG_RESULT([yes]) + HTTP_CURL_SSL_LIB_CHECK(OpenSSL, [ AC_CHECK_HEADER([openssl/ssl.h], [ AC_CHECK_HEADER([openssl/crypto.h], [ AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ]) CURL_SSL_LIBS="ssl crypto" ]) ]) - ], [ - AC_MSG_RESULT([no]) - ], [ - AC_MSG_RESULT([no]) ]) - - AC_MSG_CHECKING([for gnutls support in libcurl]) - AC_TRY_RUN([ - #include - int main(int argc, char *argv[]) { - curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); - if (data && data->ssl_version && *data->ssl_version) { - const char *ptr = data->ssl_version; - while(*ptr == ' ') ++ptr; - return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1); - } - return 1; - } - ], [ - AC_MSG_RESULT([yes]) + HTTP_CURL_SSL_LIB_CHECK(GnuTLS, [ AC_CHECK_HEADER([gnutls.h], [ AC_CHECK_HEADER([gcrypt.h], [ AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ]) CURL_SSL_LIBS="gnutls gcrypt" ]) ]) - ], [ - AC_MSG_RESULT([no]) - ], [ - AC_MSG_RESULT([no]) + ]) + HTTP_CURL_SSL_LIB_CHECK(NSS, [ + AC_DEFINE([PHP_HTTP_HAVE_NSS], [1], [ ]) + ]) + HTTP_CURL_SSL_LIB_CHECK(SecureTransport, [ + AC_DEFINE([PHP_HTTP_HAVE_DARWINSSL], [1], [ ]) + ]) + HTTP_CURL_SSL_LIB_CHECK(GSKit, [ + AC_DEFINE([PHP_HTTP_HAVE_GSKIT], [1], [ ]) ]) else + dnl no CURL_SSL AC_MSG_RESULT([no]) fi diff --git a/gen_travis_yml.php b/gen_travis_yml.php new file mode 100755 index 0000000..89ab0b2 --- /dev/null +++ b/gen_travis_yml.php @@ -0,0 +1,45 @@ +#!/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: + ["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/php_http_client_curl.c b/php_http_client_curl.c index cb53064..a4e84ce 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -528,10 +528,11 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) case CURLSSLBACKEND_QSOSSL: backend = "qsossl"; break; -#endif +#else case CURLSSLBACKEND_GSKIT: backend = "gskit"; break; +#endif case CURLSSLBACKEND_POLARSSL: backend = "polarssl"; break; @@ -554,7 +555,7 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) } #endif -#if PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL) +#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, subarray; @@ -1249,6 +1250,11 @@ static void php_http_curle_options_init(php_http_options_t *registry) 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))) { @@ -1325,6 +1331,11 @@ static void php_http_curle_options_init(php_http_options_t *registry) 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))) { @@ -1503,8 +1514,10 @@ static void php_http_curle_options_init(php_http_options_t *registry) } # endif #endif -#if PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL) - php_http_option_register(registry, ZEND_STRL("certinfo"), CURLOPT_CERTINFO, _IS_BOOL); +#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)) + if ((opt = php_http_option_register(registry, ZEND_STRL("certinfo"), CURLOPT_CERTINFO, _IS_BOOL))) { + ZVAL_FALSE(&opt->defval); + } #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))) { @@ -1530,6 +1543,9 @@ static void php_http_curle_options_init(php_http_options_t *registry) 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 } } diff --git a/php_http_env_request.c b/php_http_env_request.c index 5f1d130..0ee68f4 100644 --- a/php_http_env_request.c +++ b/php_http_env_request.c @@ -166,6 +166,7 @@ static PHP_METHOD(HttpEnvRequest, __construct) zval *this_ptr = getThis(); \ zval qs_tmp, *qs = zend_read_property(Z_OBJCE_P(this_ptr), this_ptr, ZEND_STRL(prop), 0, &qs_tmp); \ \ + ZVAL_NULL(&rv); \ array_init(&mn); \ Z_TRY_ADDREF_P(qs); \ add_next_index_zval(&mn, qs); \ diff --git a/php_http_header_parser.c b/php_http_header_parser.c index e1ebe12..5dfaedd 100644 --- a/php_http_header_parser.c +++ b/php_http_header_parser.c @@ -141,11 +141,14 @@ php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_pars const char *colon, *eol_str = NULL; int eol_len = 0; + /* fix buffer here, so eol_str pointer doesn't become obsolete afterwards */ + php_http_buffer_fix(buffer); + if (buffer->data == (eol_str = php_http_locate_bin_eol(buffer->data, buffer->used, &eol_len))) { /* end of headers */ php_http_buffer_cut(buffer, 0, eol_len); php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_DONE); - } else if (php_http_info_parse(&parser->info, php_http_buffer_fix(buffer)->data)) { + } else if (php_http_info_parse(&parser->info, buffer->data)) { /* new message starting with request/response line */ if (callback_func) { callback_func(callback_arg, &headers, &parser->info); @@ -171,7 +174,6 @@ php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_pars php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_VALUE); } else if (eol_str || (flags & PHP_HTTP_HEADER_PARSER_CLEANUP)) { /* neither reqeust/response line nor 'header:' string, or injected new line or NUL etc. */ - php_http_buffer_fix(buffer); php_http_header_parser_error(strspn(buffer->data, PHP_HTTP_HEADER_NAME_CHARS), buffer->data, buffer->used, eol_str); return php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_FAILURE); } else { diff --git a/php_http_querystring.c b/php_http_querystring.c index 589b015..5f4eff8 100644 --- a/php_http_querystring.c +++ b/php_http_querystring.c @@ -16,6 +16,9 @@ #include #ifdef PHP_HTTP_HAVE_ICONV +# ifndef HAVE_ICONV +# define HAVE_ICONV 1 +# endif # undef PHP_ATOM_INC # include #endif diff --git a/php_http_url.c b/php_http_url.c index 2c5d3f4..afe39bf 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -1290,8 +1290,11 @@ static const char *parse_query(struct parse_state *state) state->buffer[state->offset++] = *state->ptr; break; - case ']': - case '[': + /* RFC1738 unsafe */ + case '{': case '}': + case '<': case '>': + case '[': case ']': + case '|': case '\\': case '^': case '`': case '"': case ' ': if (state->flags & PHP_HTTP_URL_PARSE_TOPCT) { state->buffer[state->offset++] = '%'; state->buffer[state->offset++] = parse_xdigits[((unsigned char) *state->ptr) >> 4]; @@ -1362,6 +1365,19 @@ static const char *parse_fragment(struct parse_state *state) state->buffer[state->offset++] = *state->ptr; break; + /* RFC1738 unsafe */ + case '{': case '}': + case '<': case '>': + case '[': case ']': + case '|': case '\\': case '^': case '`': case '"': case ' ': + if (state->flags & PHP_HTTP_URL_PARSE_TOPCT) { + state->buffer[state->offset++] = '%'; + state->buffer[state->offset++] = parse_xdigits[((unsigned char) *state->ptr) >> 4]; + state->buffer[state->offset++] = parse_xdigits[((unsigned char) *state->ptr) & 0xf]; + break; + } + /* no break */ + case '?': case '/': case '!': case '$': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case ';': case '=': /* sub-delims */ diff --git a/tests/client019.phpt b/tests/client019.phpt index 9666b97..eea116a 100644 --- a/tests/client019.phpt +++ b/tests/client019.phpt @@ -6,7 +6,7 @@ include "skipif.inc"; skip_client_test(); $client = new http\Client("curl"); array_key_exists("proxyheader", $client->getAvailableOptions()) - or die("skip need libcurl with CUTLOPT_PROXYHEADER support\n"); + or die("skip need libcurl with CURLOPT_PROXYHEADER support\n"); ?> --FILE-- +--FILE-- +query; +echo "\n"; +echo (new http\Url("?id={\$id}"))->query; +echo "\n"; + +?> +===DONE=== +--EXPECT-- +Test +__utma=1152894289.1017686999.9107388726.1439222726.1494721726.1&__utmb=115739289.1.10.1437388726&__utmc=115883619&__utmx=-&__utmz=115111289.14310476.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)&__utmv=-&__utmk=112678937 +id={$id} +===DONE=== diff --git a/tests/gh-issue7.phpt b/tests/gh-issue7.phpt new file mode 100644 index 0000000..38e597c --- /dev/null +++ b/tests/gh-issue7.phpt @@ -0,0 +1,32 @@ +--TEST-- +crash with querystring and exception from error handler +--SKIPIF-- + +--GET-- +q[]=1&r[]=2 +--FILE-- +get("q","s")); +} catch (\Exception $e) { + echo $e->getMessage(),"\n"; +} +try { + $r = new http\Env\Request; + var_dump($r->getQuery("r", "s")); +} catch (\Exception $e) { + echo $e->getMessage(),"\n"; +} + +?> +===DONE=== +--EXPECT-- +Test +Array to string conversion +Array to string conversion +===DONE=== diff --git a/tests/helper/pipeline.inc b/tests/helper/pipeline.inc index b7175c1..a6b1699 100644 --- a/tests/helper/pipeline.inc +++ b/tests/helper/pipeline.inc @@ -10,17 +10,24 @@ function respond($client, $msg) { } serve(function($client) { + $R = array(STDIN); $W = $E = array(); + if (!stream_select($R, $W, $E, 10, 0)) { + logger("Client %d timed out", (int) $client); + return; + } $count = trim(fgets(STDIN)); - + logger("Expecting %d messages from client %d", $count, (int) $client); /* the peek message */ respond($client, new http\Message($client, false)); - + logger("Handled the peek request of client %d", (int) $client); /* pipelined messages */ $req = array(); for ($i=0; $i < $count; ++ $i) { $req[] = new http\Message($client, false); + logger("Read request no. %d from client %d", $i+1, (int) $client); } - foreach ($req as $msg) { + foreach ($req as $i => $msg) { respond($client, $msg); + logger("Sent response no. %d to client %d", $i+1, (int) $client); } }); diff --git a/tests/helper/server.inc b/tests/helper/server.inc index a13dc12..091ff5c 100644 --- a/tests/helper/server.inc +++ b/tests/helper/server.inc @@ -1,5 +1,19 @@ getMessage()); /* ignore disconnect */ if ($ex->getMessage() !== "Empty message received from stream") { fprintf(STDERR, "%s\n", $ex); @@ -49,7 +69,7 @@ function serve($cb) { break; } } - } while ($select !== false); + } while ($select); return; } } @@ -123,4 +143,4 @@ function proc($bin, $args, $cb) { fpassthru($stderr); fpassthru($stdout); } -} \ No newline at end of file +} diff --git a/tests/message002.phpt b/tests/message002.phpt index e16f8dc..573fdbd 100644 --- a/tests/message002.phpt +++ b/tests/message002.phpt @@ -19,6 +19,11 @@ use http\env\Request as HttpEnvRequest; $m = new HttpEnvRequest(); +// travis' env headers have another order, wtf? +$h = $m->getHeaders(); +ksort($h); +$m->setHeaders($h); + var_dump($m); echo "Message->toString\n"; @@ -50,14 +55,14 @@ object(%s)#%d (13) { string(3) "1.1" ["headers":protected]=> array(4) { - ["X-Test"]=> - string(4) "test" ["Content-Length"]=> string(1) "3" ["Content-Type"]=> string(14) "test/something" ["Cookie"]=> string(7) "foo=bar" + ["X-Test"]=> + string(4) "test" } ["parentMessage":protected]=> NULL @@ -87,10 +92,10 @@ object(%s)#%d (13) { } Message->toString POST / HTTP/1.1%a -X-Test: test%a Content-Length: 3%a Content-Type: test/something%a Cookie: foo=bar%a +X-Test: test%a %a b=c Body->toString diff --git a/travis/pecl b/travis/pecl new file mode 160000 index 0000000..0815aa6 --- /dev/null +++ b/travis/pecl @@ -0,0 +1 @@ +Subproject commit 0815aa6d8727870e6bf8409700925abfaaf2b723