AC_DEFUN([PECL_CHECK_LIBBROTLI], [
+ dnl config.m4 calls PECL_CHECK_DONE once more
+ PECL_COUNT_CHECKS([+1])
+ PECL_SAVE_ENV([CPPFLAGS], [libbrotli])
+ PECL_SAVE_ENV([LDFLAGS], [libbrotli])
+ PECL_SAVE_ENV([LIBS], [libbrotli])
+
PECL_CHECK_LIBBROTLI_COMMON([$1], [$2])
PECL_CHECK_DONE(libbrotlicommon, [$PECL_VAR([HAVE_LIBBROTLI_COMMON])])
PECL_CHECK_LIBBROTLI_DEC([$1], [$2])
fi
fi
])
+
+ PECL_HAVE_CONST([curl/curl.h], [CURL_LOCK_DATA_SSL_SESSION], int, [
+ AC_CACHE_CHECK([whether curl_share accepts CURL_LOCK_DATA_SSL_SESSION], PECL_CACHE_VAR([LIBCURL_SHARE_SSL]), [
+ PECL_CACHE_VAR([LIBCURL_SHARE_SSL])=
+ AC_TRY_RUN([
+ #include <curl/curl.h>
+ int main(int argc, char *argv[]) {
+ CURLSH *ch = curl_share_init();
+ return curl_share_setopt(ch, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
+ }
+ ], [
+ PECL_CACHE_VAR([LIBCURL_SHARE_SSL])=yes
+ ], [
+ PECL_CACHE_VAR([LIBCURL_SHARE_SSL])=no
+ ])
+ ])
+ if test "$PECL_CACHE_VAR([LIBCURL_SHARE_SSL])" = yes; then
+ PECL_DEFINE([HAVE_LIBCURL_SHARE_SSL], [1])
+ fi
+ ])
+
+ if test "$PECL_VAR([LIBCURL_SSLLIB])" == "OpenSSL"; then
+ PECL_HAVE_CONST([curl/curl.h], [CURLOPT_TLS13_CIPHERS], int, [
+ AC_CACHE_CHECK([whether curl_easy_setopt accepts CURLOPT_TLS13_CIPHERS], PECL_CACHE_VAR([LIBCURL_TLS13_CIPHERS]), [
+ PECL_CACHE_VAR([LIBCURL_TLS13_CIPHERS])=
+ AC_TRY_RUN([
+ #include <curl/curl.h>
+ int main(int argc, char *argv[]) {
+ CURL *ch = curl_easy_init();
+ return curl_easy_setopt(ch, CURLSHOPT_TLS13_CIPHERS, "");
+ }
+ ], [
+ PECL_CACHE_VAR([LIBCURL_TLS13_CIPHERS])=yes
+ ], [
+ PECL_CACHE_VAR([LIBCURL_TLS13_CIPHERS])=no
+ ])
+ ])
+ if test "$PECL_CACHE_VAR([LIBCURL_TLS13_CIPHERS])" = yes; then
+ PECL_DEFINE([HAVE_LIBCURL_TLS13_CIPHERS], [1])
+ fi
+ ])
+ fi
])
])
dnl
$1=$PECL_SAVE_VAR([$2_$1])
])
dnl
+dnl PECL_COUNT_CHECKS(incdec)
+dnl
+AC_DEFUN([PECL_COUNT_CHECKS], [
+ PECL_VAR([_checks])=$(($PECL_VAR([_checks])$1))
+])
+dnl
dnl PECL_EVAL_LIBLINE(libline)
dnl
AC_DEFUN([PECL_EVAL_LIBLINE], [
dnl PECL_CHECK_CUSTOM(name, path, header, lib, version)
dnl
AC_DEFUN([PECL_CHECK_CUSTOM], [
+ PECL_COUNT_CHECKS([+1])
PECL_SAVE_ENV([CPPFLAGS], [$1])
PECL_SAVE_ENV([LDFLAGS], [$1])
PECL_SAVE_ENV([LIBS], [$1])
done
])
if test -n "$PECL_CACHE_VAR([$1_prefix])"; then
- CPPFLAGS="-I$PECL_CACHE_VAR([$1_prefix])/include"
- LDFLAGS="-L$PECL_CACHE_VAR([$1_prefix])/$PHP_LIBDIR"
- LIBS="-l$4"
- PECL_EVAL_LIBLINE([$LDFLAGS $LIBS])
+ CPPFLAGS="$CPPFLAGS -I$PECL_CACHE_VAR([$1_prefix])/include"
+ LDFLAGS="$LDFLAGS -L$PECL_CACHE_VAR([$1_prefix])/$PHP_LIBDIR"
+ LIBS="$LIBS -l$4"
+ dnl PECL_EVAL_LIBLINE([$LDFLAGS $LIBS])
AC_CACHE_VAL(PECL_CACHE_VAR([$1_version]), [
pushd $PECL_CACHE_VAR([$1_prefix]) >/dev/null
dnl PECL_CHECK_CONFIG(name, prog-config, version-flag, cppflags-flag, ldflags-flag, libs-flag)
dnl
AC_DEFUN([PECL_CHECK_CONFIG], [
+ PECL_COUNT_CHECKS([+1])
PECL_SAVE_ENV([CPPFLAGS], [$1])
PECL_SAVE_ENV([LDFLAGS], [$1])
PECL_SAVE_ENV([LIBS], [$1])
-
AC_MSG_CHECKING([for $1])
ifelse($2, [$PKG_CONFIG $1], [
AC_CACHE_VAL(PECL_CACHE_VAR([$1_exists]), [
AC_CACHE_VAL(PECL_CACHE_VAR([$1_cppflags]), [
PECL_CACHE_VAR([$1_cppflags])=$($2 $4)
])
- CPPFLAGS=$PECL_CACHE_VAR([$1_cppflags])
+ CPPFLAGS="$CPPFLAGS $PECL_CACHE_VAR([$1_cppflags])"
AC_CACHE_VAL(PECL_CACHE_VAR([$1_ldflags]), [
PECL_CACHE_VAR([$1_ldflags])=$($2 $5)
])
- LDFLAGS=$PECL_CACHE_VAR([$1_ldflags])
+ LDFLAGS="$LDFLAGS $PECL_CACHE_VAR([$1_ldflags])"
AC_CACHE_VAL(PECL_CACHE_VAR([$1_libs]), [
PECL_CACHE_VAR([$1_libs])=$($2 $6)
])
- LIBS=$PECL_CACHE_VAR([$1_libs])
- PECL_EVAL_LIBLINE([$LDFLAGS $LIBS])
+ LIBS="$LIBS $PECL_CACHE_VAR([$1_libs])"
+ dnl PECL_EVAL_LIBLINE([$LDFLAGS $LIBS])
ifelse($2, [$PKG_CONFIG $1], [
fi
])
+ AC_MSG_RESULT([${PECL_CHECKED_VERSION([$1]):-no}])
+
if test -n "$PECL_CHECKED_VERSION([$1])"; then
PECL_VAR([HAVE_$1])=true
PECL_DEFINE([HAVE_$1])
else
PECL_VAR([HAVE_$1])=false
fi
-
- AC_MSG_RESULT([${PECL_CHECKED_VERSION([$1]):-no}])
])
dnl
dnl PECL_CHECK_PKGCONFIG(pkg[, additional-pkg-config-path])
dnl PECL_CHECK_DONE(name, success[, incline, libline])
dnl
AC_DEFUN([PECL_CHECK_DONE], [
- if $2; then
- incline=$CPPFLAGS
- libline="$LDFLAGS $LIBS"
+ PECL_COUNT_CHECKS([-1])
+ success=$2
+ if $success && test -n "$LDFLAGS$LIBS"; then
+ AC_MSG_CHECKING([whether $1 can be linked])
+ AC_TRY_LINK([], [], [success=yes], [success=no])
+ AC_MSG_RESULT([$success])
+ if ! $success; then
+ AC_MSG_WARN([$1 was found, but fails to link with:])
+ AC_MSG_WARN([ LDFLAGS='$LDFLAGS'])
+ AC_MSG_WARN([ LIBS='$LIBS'])
+ AC_MSG_WARN([Missing or updated library paths?])
+ fi
+ fi
+ if $success; then
+ _cppflags=$PECL_SAVE_VAR([$1_CPPFLAGS])
+ _ldflags=$PECL_SAVE_VAR([$1_LDFLAGS])
+ _libs=$PECL_SAVE_VAR([$1_LIBS])
+ incline=${CPPFLAGS:${#_cppflags}}
+ libline=["${LDFLAGS:${#_ldflags}} ${LIBS:${#_libs}}"]
PECL_DEFINE([HAVE_$1])
else
incline=$3
AC_CHECK_LIB(nsl, getdomainname)
])
AC_CHECK_FUNCS(mbrtowc mbtowc iswalnum inet_pton)
+
+ CFLAGS="$CFLAGS -Wno-strict-prototypes"
dnl ZLIB
PHP_ARG_WITH([http-zlib-dir], [whether/where to check for zlib],
#if PHP_HTTP_HAVE_LIBCURL
+#define DEBUG_COOKIES 0
+
#if PHP_HTTP_HAVE_LIBCURL_OPENSSL
# include <openssl/ssl.h>
#endif
return FAILURE;
}
if (Z_TYPE_P(val) == IS_TRUE) {
+#if DEBUG_COOKIES
+ fprintf(stderr, "CURLOPT_COOKIELIST: SESS\n");
+#endif
if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIELIST, "SESS")) {
return FAILURE;
}
} else {
storage->cookiestore = NULL;
}
- if ( CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore ? storage->cookiestore : "")
- || CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore)
- ) {
+
+#if DEBUG_COOKIES
+ fprintf(stderr, "CURLOPT_COOKIEFILE: %s\n", cookiestore);
+#endif
+ // does NOT enable ch->data.cookies until transfer; adds to ch->stsate.cookielist
+ if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore ? storage->cookiestore : "")) {
+ return FAILURE;
+ }
+#if DEBUG_COOKIES
+ fprintf(stderr, "CURLOPT_COOKIEJAR: %s\n", cookiestore);
+#endif
+ // enables ch->data.cookies
+ if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore)) {
return FAILURE;
}
opt->flags |= PHP_HTTP_CURLE_OPTION_IGNORE_RC;
}
#endif
-#if PHP_HTTP_CURL_VERSION(7,61,0)
+#if PHP_HTTP_CURL_VERSION(7,61,0) && PHP_HTTP_HAVE_LIBCURL_TLS13_CIPHERS
if ((opt = php_http_option_register(ssl_registry, ZEND_STRL("tls13_ciphers"), CURLOPT_TLS13_CIPHERS, 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,61,0)
+# if PHP_HTTP_CURL_VERSION(7,61,0) && PHP_HTTP_HAVE_LIBCURL_TLS13_CIPHERS
if ((opt = php_http_option_register(proxy_registry, ZEND_STRL("tls13_ciphers"), CURLOPT_PROXY_TLS13_CIPHERS, IS_STRING))) {
opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
}
return SUCCESS;
}
-#if PHP_HTTP_CURL_VERSION(7,23,0)
+#if PHP_HTTP_HAVE_LIBCURL_SHARE_SSL
static ZEND_RESULT_CODE php_http_curlm_option_set_share_ssl(php_http_option_t *opt, zval *value, void *userdata)
{
php_http_client_t *client = userdata;
opt->setter = php_http_curlm_option_set_share_cookies;
ZVAL_TRUE(&opt->defval);
}
-#if PHP_HTTP_CURL_VERSION(7,23,0)
+#if PHP_HTTP_HAVE_LIBCURL_SHARE_SSL
if ((opt = php_http_option_register(registry, ZEND_STRL("share_ssl"), 0, _IS_BOOL))) {
opt->setter = php_http_curlm_option_set_share_ssl;
ZVAL_TRUE(&opt->defval);
/* client ops */
-static ZEND_RESULT_CODE php_http_client_curl_handler_reset(php_http_client_curl_handler_t *curl)
+static ZEND_RESULT_CODE php_http_client_curl_handler_reset(php_http_client_curl_handler_t *handler)
{
- CURL *ch = curl->handle;
+ php_http_client_curl_t *curl = handler->client->ctx;
+ CURL *ch = handler->handle;
php_http_curle_storage_t *st;
if ((st = php_http_curle_get_storage(ch))) {
#endif
#if PHP_HTTP_CURL_VERSION(7,21,3)
- if (curl->options.resolve) {
- curl_slist_free_all(curl->options.resolve);
- curl->options.resolve = NULL;
+ if (handler->options.resolve) {
+ curl_slist_free_all(handler->options.resolve);
+ handler->options.resolve = NULL;
}
#endif
- curl->options.retry.count = 0;
- curl->options.retry.delay = 0;
- curl->options.redirects = 0;
- curl->options.encode_cookies = 1;
+ handler->options.retry.count = 0;
+ handler->options.retry.delay = 0;
+ handler->options.redirects = 0;
+ handler->options.encode_cookies = 1;
- if (curl->options.headers) {
- curl_slist_free_all(curl->options.headers);
- curl->options.headers = NULL;
+ if (handler->options.headers) {
+ curl_slist_free_all(handler->options.headers);
+ handler->options.headers = NULL;
}
- if (curl->options.proxyheaders) {
- curl_slist_free_all(curl->options.proxyheaders);
- curl->options.proxyheaders = NULL;
+ if (handler->options.proxyheaders) {
+ curl_slist_free_all(handler->options.proxyheaders);
+ handler->options.proxyheaders = NULL;
}
- php_http_buffer_reset(&curl->options.cookies);
- php_http_buffer_reset(&curl->options.ranges);
+ php_http_buffer_reset(&handler->options.cookies);
+ php_http_buffer_reset(&handler->options.ranges);
+
+#if ZTS
+ curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L);
+#endif
+ curl_easy_setopt(ch, CURLOPT_HEADER, 0L);
+ curl_easy_setopt(ch, CURLOPT_FILETIME, 1L);
+ curl_easy_setopt(ch, CURLOPT_AUTOREFERER, 1L);
+ curl_easy_setopt(ch, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 0L);
+ curl_easy_setopt(ch, CURLOPT_HEADERFUNCTION, php_http_curle_header_callback);
+ curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, php_http_curle_body_callback);
+ curl_easy_setopt(ch, CURLOPT_DEBUGFUNCTION, php_http_curle_raw_callback);
+ curl_easy_setopt(ch, CURLOPT_READFUNCTION, php_http_curle_read_callback);
+ curl_easy_setopt(ch, CURLOPT_SEEKFUNCTION, php_http_curle_seek_callback);
+#if PHP_HTTP_CURL_VERSION(7,32,0)
+ curl_easy_setopt(ch, CURLOPT_XFERINFOFUNCTION, php_http_curle_xferinfo_callback);
+ curl_easy_setopt(ch, CURLOPT_XFERINFODATA, handler);
+#else
+ curl_easy_setopt(ch, CURLOPT_PROGRESSFUNCTION, php_http_curle_progress_callback);
+ curl_easy_setopt(ch, CURLOPT_PROGRESSDATA, handler);
+#endif
+ curl_easy_setopt(ch, CURLOPT_DEBUGDATA, handler);
+ curl_easy_setopt(ch, CURLOPT_WRITEDATA, handler);
+ curl_easy_setopt(ch, CURLOPT_HEADERDATA, handler);
+#if DEBUG_COOKIES
+ fprintf(stderr, "CURLOPT_SHARE: %p\n", curl->handle->share);
+#endif
+ curl_easy_setopt(ch, CURLOPT_SHARE, curl->handle->share);
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_t *curl = h->ctx;
php_http_client_curl_handler_t *handler;
if (!(handle = php_resource_factory_handle_ctor(rf, NULL))) {
php_http_buffer_init(&handler->options.ranges);
zend_hash_init(&handler->options.cache, 0, NULL, ZVAL_PTR_DTOR, 0);
-#if 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);
- curl_easy_setopt(handle, CURLOPT_SHARE, curl->handle->share);
-
php_http_client_curl_handler_reset(handler);
return handler;
#endif
curl_easy_setopt(handler->handle, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(handler->handle, CURLOPT_DEBUGFUNCTION, NULL);
- curl_easy_setopt(handler->handle, CURLOPT_COOKIELIST, "FLUSH");
- curl_easy_setopt(handler->handle, CURLOPT_SHARE, NULL);
/* see gh issue #84 */
#if PHP_HTTP_CURL_VERSION(7,63,0) && !PHP_HTTP_CURL_VERSION(7,65,0)
- curl_easy_setopt(handler->handle, CURLOPT_COOKIEJAR, NULL);
+ {
+ php_http_curle_storage_t *st = php_http_curle_get_storage(handler->handle);
+ curl_easy_setopt(handler->handle, CURLOPT_COOKIEJAR, st ? st->cookiestore : NULL);
+ }
+#endif
+#if DEBUG_COOKIES
+ fprintf(stderr, "CURLOPT_COOKIELIST: FLUSH\n");
+ fprintf(stderr, "CURLOPT_SHARE: (null)\n");
#endif
+ curl_easy_setopt(handler->handle, CURLOPT_COOKIELIST, "FLUSH");
+ curl_easy_setopt(handler->handle, CURLOPT_SHARE, NULL);
}
static void php_http_client_curl_handler_dtor(php_http_client_curl_handler_t *handler)
#[ReturnTypeWillChange]
function update(SplSubject $client, http\Client\Request $request = null, StdClass $progress = null) {
echo "P";
- if ($progress->info !== "prepare" && $client->getProgressInfo($request) != $progress) {
- var_dump($progress);
+ /* fence against buggy infof() calls in some curl versions */
+ $compare = $client->getProgressInfo($request);
+ if ($progress->info !== "prepare" && $compare && $compare != $progress) {
+ var_dump($progress, $compare);
}
}
}
<?php
include "skipif.inc";
skip_client_test();
+if (0 === strpos(http\Client\Curl\Versions\CURL, "7.64.0")) {
+ die("skip - cookie handling broken or crashes with libcurl-7.64\n");
+}
?>
--FILE--
<?php
server("cookie.inc", function($port) {
$client = new http\Client(null, "cookies");
- $client->configure(array("pipelining" => false));
+ $client->configure(array("pipelining" => false, "share_cookies" => false));
+
$request = new http\Client\Request("GET", "http://localhost:$port?r1");
$client->enqueue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
+ dump_responses($client, ["counter" => 1]);
+
$client->requeue($request);
+ $client->send();
+ dump_responses($client, ["counter" => 2]);
+
$request = new http\Client\Request("GET", "http://localhost:$port?r2");
$client->enqueue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
+ dump_responses($client, ["counter" => 1]);
});
?>
X-Original-Transfer-Encoding: chunked
Etag: ""
-Set-Cookie: counter=2;
+Set-Cookie: counter=1;
X-Original-Transfer-Encoding: chunked
===DONE===
server("cookie.inc", function($port) {
$client = new http\Client(null, "cookies");
$client->configure(array("share_cookies" => false));
+
$request = new http\Client\Request("GET", "http://localhost:$port");
$client->enqueue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
+ dump_responses($client, ["counter" => 1]);
+
/* requeue the previous request */
$client->requeue($request);
- $request = new http\Client\Request("GET", "http://localhost:$port");
- $client->enqueue($request);
- $client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
- $request = new http\Client\Request("GET", "http://localhost:$port");
- $client->enqueue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
+ dump_responses($client, ["counter" => 2]);
+
+ for($i = 0; $i < 3; ++$i) {
+ /* new requests */
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+ $client->enqueue($request);
+ $client->send();
+ dump_responses($client, ["counter" => 1]);
}
- $request = new http\Client\Request("GET", "http://localhost:$port");
- $client->enqueue($request);
+
+ /* requeue the previous request */
+ $client->requeue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
+ dump_responses($client, ["counter" => 2]);
});
?>
X-Original-Transfer-Encoding: chunked
Etag: ""
-Set-Cookie: counter=1;
+Set-Cookie: counter=2;
X-Original-Transfer-Encoding: chunked
Etag: ""
-Set-Cookie: counter=2;
+Set-Cookie: counter=1;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=1;
X-Original-Transfer-Encoding: chunked
+Etag: ""
+Set-Cookie: counter=2;
+X-Original-Transfer-Encoding: chunked
+
===DONE===
server("cookie.inc", function($port) {
$client = new http\Client(null, "cookies");
$client->configure(array("share_cookies" => true));
+
$request = new http\Client\Request("GET", "http://localhost:$port");
$client->enqueue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
+ dump_responses($client, ["counter" => 1]);
+
/* requeue the previous request */
$client->requeue($request);
- $request = new http\Client\Request("GET", "http://localhost:$port");
- $client->enqueue($request);
- $client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
- $request = new http\Client\Request("GET", "http://localhost:$port");
- $client->enqueue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
+ dump_responses($client, ["counter" => 2]);
+
+ for($i = 3; $i < 6; ++$i) {
+ /* new requests */
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+ $client->enqueue($request);
+ $client->send();
+ dump_responses($client, ["counter" => $i]);
}
- $request = new http\Client\Request("GET", "http://localhost:$port");
- $client->enqueue($request);
+
+ /* requeue the previous request */
+ $client->requeue($request);
$client->send();
- while (($r = $client->getResponse())) {
- dump_headers(null, $r->getHeaders());
- }
+ dump_responses($client, ["counter" => $i]);
});
?>
X-Original-Transfer-Encoding: chunked
Etag: ""
-Set-Cookie: counter=2;
+Set-Cookie: counter=3;
X-Original-Transfer-Encoding: chunked
Etag: ""
-Set-Cookie: counter=3;
+Set-Cookie: counter=4;
X-Original-Transfer-Encoding: chunked
Etag: ""
-Set-Cookie: counter=4;
+Set-Cookie: counter=5;
+X-Original-Transfer-Encoding: chunked
+
+Etag: ""
+Set-Cookie: counter=6;
X-Original-Transfer-Encoding: chunked
===DONE===
}
}
-?>
\ No newline at end of file
+function dump_responses($client, array $expect_cookie = []) {
+ while (($r = $client->getResponse())) {
+ dump_headers(null, $r->getHeaders());
+ if ($expect_cookie) {
+ $got_cookies = array_merge(...array_map(fn($c) => $c->getCookies(), $r->getCookies()));
+ if ($expect_cookie != $got_cookies) {
+ var_dump($expect_cookie, $got_cookies);
+ echo $r->toString(true);
+ }
+ }
+ }
+
+}
+?>