X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_functions.c;h=a22bea3d98219f597588cd0b73b2063fa50c4137;hb=bcda0df869eb6c34df1b3ec6888070c76bb33065;hp=33c1e4a34a3a856826ae94ae6fe3cab0b721d1fe;hpb=2655b1c8838edb32ef8ac67376f123e8d613a9af;p=m6w6%2Fext-http diff --git a/http_functions.c b/http_functions.c index 33c1e4a..a22bea3 100644 --- a/http_functions.c +++ b/http_functions.c @@ -1068,7 +1068,7 @@ PHP_FUNCTION(http_parse_cookie) FOREACH_VAL(pos, allowed_extras_array, entry) { ZVAL_ADDREF(*entry); convert_to_string_ex(entry); - allowed_extras[i] = estrndup(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry)); + allowed_extras[i++] = estrndup(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry)); zval_ptr_dtor(entry); } } @@ -1088,6 +1088,30 @@ PHP_FUNCTION(http_parse_cookie) efree(allowed_extras); } } +/* }}} */ + +/* {{{ proto string http_build_cookie(array cookie) + * + * Build a cookie string from an array/object like returned by http_parse_cookie(). + */ +PHP_FUNCTION(http_build_cookie) +{ + char *str = NULL; + size_t len = 0; + zval *strct; + http_cookie_list list; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &strct)) { + RETURN_FALSE; + } + + http_cookie_list_fromstruct(&list, strct); + http_cookie_list_tostring(&list, &str, &len); + http_cookie_list_dtor(&list); + + RETURN_STRINGL(str, len, 0); +} +/* }}} */ /* {{{ proto object http_parse_params(string param[, int flags = HTTP_PARAMS_DEFAULT]) * @@ -1959,8 +1983,22 @@ PHP_FUNCTION(http_support) } /* }}} */ +#include "zend_exceptions.h" PHP_FUNCTION(http_test) { + int i; + + for (i = 0; i < 3; ++i) { + http_try { + fprintf(stderr, "Throwing Ex %d\n", i); + http_error_ex(HE_THROW, HTTP_E_RUNTIME, "Ex %d", i); + http_try { + fprintf(stderr, "Throwing SubEx %d\n", i); + http_error_ex(HE_THROW, HTTP_E_RUNTIME, "SubEx %d", i); + } http_catch(ZEND_EXCEPTION_GET_DEFAULT()); + } http_catch(ZEND_EXCEPTION_GET_DEFAULT()); + } + http_final(ZEND_EXCEPTION_GET_DEFAULT()); } /*