static STATUS handle_response(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_message_t **request, php_http_message_t **response)
{
+ zend_bool dequeue = 0;
zval zclient;
php_http_message_t *msg;
php_http_client_progress_state_t *progress;
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, *request, *response TSRMLS_CC);
}
zend_fcall_info_argn(&e->closure.fci TSRMLS_CC, 0);
if (retval) {
- if (Z_TYPE_P(retval) == IS_BOOL && Z_BVAL_P(retval)) {
- php_http_client_dequeue(client, e->request);
+ if (Z_TYPE_P(retval) == IS_BOOL) {
+ dequeue = Z_BVAL_P(retval);
}
zval_ptr_dtor(&retval);
}
client->callback.progress.func(client->callback.progress.arg, client, e, progress);
}
+ if (dequeue) {
+ php_http_client_dequeue(client, e->request);
+ }
+
return SUCCESS;
}