#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
#include "php_http_std_defs.h"
+#include "php_http_api.h"
#include "php_http_requestpool_object.h"
#include "php_http_request_pool_api.h"
#include "php_http_request_object.h"
getObject(http_requestpool_object, obj);
NO_ARGS;
-
+
+ obj->iterator.pos = 0;
http_request_pool_detach_all(&obj->pool);
}
SET_EH_THROW_HTTP();
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, http_request_object_ce)) {
- status = http_request_pool_attach(&obj->pool, request);
+ if (obj->iterator.pos > 0 && obj->iterator.pos < zend_llist_count(&obj->pool.handles)) {
+ http_error(HE_THROW, HTTP_E_REQUEST_POOL, "Cannot attach to the HttpRequestPool while the iterator is active");
+ } else {
+ status = http_request_pool_attach(&obj->pool, request);
+ }
}
SET_EH_NORMAL();
RETURN_SUCCESS(status);
SET_EH_THROW_HTTP();
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &request, http_request_object_ce)) {
+ obj->iterator.pos = -1;
status = http_request_pool_detach(&obj->pool, request);
}
SET_EH_NORMAL();
IF_RETVAL_USED {
getObject(http_requestpool_object, obj);
- RETURN_BOOL(obj->iterator.pos < zend_llist_count(&obj->pool.handles));
+ RETURN_BOOL(obj->iterator.pos >= 0 && obj->iterator.pos < zend_llist_count(&obj->pool.handles));
}
}
/* }}} */
$req->getResponseCode(), ':',
$req->getResponseMessage()->getResponseCode(), "\n";
}
+foreach ($pool as $req) {
+ try {
+ $pool->attach(new HttpRequest('http://foo.bar'));
+ } catch (HttpRequestPoolException $x) {
+ echo ".\n";
+ }
+}
+foreach ($pool as $req) {
+ $pool->detach($req);
+}
echo "Done\n";
?>
--EXPECTF--
http://pear.php.net/=200:200
http://pecl.php.net/=200:200
http://dev.iworks.at/.print_request.php=200:200
+.
+.
+.
+.
Done