X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_response_object.c;h=011944d71e7f0b5ae6a03a437cf79ba281356c2b;hb=51c3a4d29b5b0ada721d8f0c9aa55581079bdf91;hp=e011e7e16c671f0c2c526dcaf15422bee736e85f;hpb=1a0dbb96fbe46a2edec1c813798cef7b0898eebe;p=m6w6%2Fext-http diff --git a/http_response_object.c b/http_response_object.c index e011e7e..011944d 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -72,6 +72,7 @@ HTTP_EMPTY_ARGS(getCacheControl); HTTP_BEGIN_ARGS(setCacheControl, 1) HTTP_ARG_VAL(cache_control, 0) HTTP_ARG_VAL(max_age, 0) + HTTP_ARG_VAL(must_revalidate, 0) HTTP_END_ARGS; HTTP_EMPTY_ARGS(getContentType); @@ -444,13 +445,15 @@ PHP_METHOD(HttpResponse, getGzip) } /* }}} */ -/* {{{ proto static bool HttpResponse::setCacheControl(string control[, int max_age = 0]) +/* {{{ proto static bool HttpResponse::setCacheControl(string control[, int max_age = 0[, bool must_revalidate = true]]) * * Set a custom cache-control header, usually being "private" or "public"; * The max_age parameter controls how long the cache entry is valid on the client side. * * Expects a string parameter containing the primary cache control setting. * Additionally accepts an int parameter specifying the max-age setting. + * Accepts an optional third bool parameter indicating whether the cache + * must be revalidated every request. * * Returns TRUE on success, or FALSE if control does not match one of * "public" , "private" or "no-cache". @@ -462,8 +465,9 @@ PHP_METHOD(HttpResponse, setCacheControl) char *ccontrol, *cctl; int cc_len; long max_age = 0; + zend_bool must_revalidate = 1; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &ccontrol, &cc_len, &max_age)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lb", &ccontrol, &cc_len, &max_age, &must_revalidate)) { RETURN_FALSE; } @@ -471,7 +475,7 @@ PHP_METHOD(HttpResponse, setCacheControl) http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Cache-Control '%s' doesn't match public, private or no-cache", ccontrol); RETURN_FALSE; } else { - size_t cctl_len = spprintf(&cctl, 0, "%s, must-revalidate, max-age=%ld", ccontrol, max_age); + size_t cctl_len = spprintf(&cctl, 0, "%s,%s max-age=%ld", ccontrol, must_revalidate?" must-revalidate,":"", max_age); RETVAL_SUCCESS(UPD_STATIC_STRL(cacheControl, cctl, cctl_len)); efree(cctl); } @@ -1085,7 +1089,7 @@ PHP_METHOD(HttpResponse, send) if (clean_ob) { /* interrupt on-the-fly etag generation */ - HTTP_G(etag).started = 0; + HTTP_G->etag.started = 0; /* discard previous output buffers */ php_end_ob_buffers(0 TSRMLS_CC); } @@ -1145,17 +1149,17 @@ PHP_METHOD(HttpResponse, send) { zval *bsize_p, *bsize = convert_to_type_ex(IS_LONG, GET_STATIC_PROP(bufferSize), &bsize_p); zval *delay_p, *delay = convert_to_type_ex(IS_DOUBLE, GET_STATIC_PROP(throttleDelay), &delay_p); - HTTP_G(send).buffer_size = Z_LVAL_P(bsize); - HTTP_G(send).throttle_delay = Z_DVAL_P(delay); + HTTP_G->send.buffer_size = Z_LVAL_P(bsize); + HTTP_G->send.throttle_delay = Z_DVAL_P(delay); if (bsize_p) zval_ptr_dtor(&bsize_p); if (delay_p) zval_ptr_dtor(&delay_p); } /* gzip */ - HTTP_G(send).deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip)); + HTTP_G->send.deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip)); /* start ob */ - php_start_ob_buffer(NULL, HTTP_G(send).buffer_size, 0 TSRMLS_CC); + php_start_ob_buffer(NULL, HTTP_G->send.buffer_size, 0 TSRMLS_CC); /* send */ switch (Z_LVAL_P(GET_STATIC_PROP(mode)))