- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|d", &chunk_size, &delay)) {
- set_option(getThis(), ZEND_STRL("throttleDelay"), IS_DOUBLE, &delay, 0 TSRMLS_CC);
- set_option(getThis(), ZEND_STRL("throttleChunk"), IS_LONG, &chunk_size, 0 TSRMLS_CC);
- RETURN_TRUE;
- }
- RETURN_FALSE;
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|d", &chunk_size, &delay), invalid_arg, return);
+
+ set_option(getThis(), ZEND_STRL("throttleDelay"), IS_DOUBLE, &delay, 0 TSRMLS_CC);
+ set_option(getThis(), ZEND_STRL("throttleChunk"), IS_LONG, &chunk_size, 0 TSRMLS_CC);
+ RETVAL_ZVAL(getThis(), 1, 0);
+}
+
+ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setCookie, 0, 0, 1)
+ ZEND_ARG_INFO(0, cookie)
+ZEND_END_ARG_INFO();
+static PHP_METHOD(HttpEnvResponse, setCookie)
+{
+ zval *zcookie_new;
+ zend_error_handling zeh;
+ php_http_cookie_list_t *list = NULL;
+
+ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zcookie_new), invalid_arg, return);
+
+ zend_replace_error_handling(EH_THROW, php_http_exception_unexpected_val_class_entry, &zeh TSRMLS_CC);
+ switch (Z_TYPE_P(zcookie_new)) {
+ case IS_OBJECT:
+ if (instanceof_function(Z_OBJCE_P(zcookie_new), php_http_cookie_class_entry TSRMLS_CC)) {
+ Z_ADDREF_P(zcookie_new);
+ break;
+ }
+ /* no break */
+ case IS_ARRAY:
+ list = php_http_cookie_list_from_struct(NULL, zcookie_new TSRMLS_CC);
+ MAKE_STD_ZVAL(zcookie_new);
+ ZVAL_OBJVAL(zcookie_new, php_http_cookie_object_new_ex(php_http_cookie_class_entry, list, NULL TSRMLS_CC), 0);
+ break;
+
+ default:
+ zcookie_new = php_http_ztyp(IS_STRING, zcookie_new);
+ list = php_http_cookie_list_parse(NULL, Z_STRVAL_P(zcookie_new), Z_STRLEN_P(zcookie_new), 0, NULL TSRMLS_CC);
+ zval_ptr_dtor(&zcookie_new);
+ MAKE_STD_ZVAL(zcookie_new);
+ ZVAL_OBJVAL(zcookie_new, php_http_cookie_object_new_ex(php_http_cookie_class_entry, list, NULL TSRMLS_CC), 0);
+ }
+ zend_restore_error_handling(&zeh TSRMLS_CC);
+
+ set_cookie(getThis(), zcookie_new TSRMLS_CC);
+ zval_ptr_dtor(&zcookie_new);
+
+ RETVAL_ZVAL(getThis(), 1, 0);