From: Michael Wallner Date: Sun, 9 Dec 2012 22:21:31 +0000 (+0000) Subject: fix caching by last modified X-Git-Tag: RELEASE_2_1_0_RC3~10^2^2~88 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b9b940d68c0569107bf1afefeca2a1e5f1efab04;p=m6w6%2Fext-http fix caching by last modified honor throttle rate fix leaks --- diff --git a/php_http_env_response.c b/php_http_env_response.c index d88fb72..57aee2e 100644 --- a/php_http_env_response.c +++ b/php_http_env_response.c @@ -166,7 +166,7 @@ PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_last_mod ums = php_parse_date(header, NULL); efree(header); - if (ums > 0 && ums <= lm) { + if (ums > 0 && ums >= lm) { return PHP_HTTP_CACHE_HIT; } else { return PHP_HTTP_CACHE_MISS; @@ -392,6 +392,7 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r) php_http_buffer_dtor(&buf); zval_ptr_dtor(&zoption_copy); + zval_ptr_dtor(&zoption); } if (ret != SUCCESS) { @@ -513,7 +514,7 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r) static STATUS php_http_env_response_send_body(php_http_env_response_t *r) { STATUS ret = SUCCESS; - zval *zbody; + zval *zbody, *zoption; TSRMLS_FETCH_FROM_CTX(r->ts); if (r->done) { @@ -526,6 +527,19 @@ static STATUS php_http_env_response_send_body(php_http_env_response_t *r) ) { php_http_message_body_object_t *obj = zend_object_store_get_object(zbody TSRMLS_CC); + if ((zoption = get_option(r->options, ZEND_STRL("throttleDelay") TSRMLS_CC))) { + if (Z_TYPE_P(zoption) == IS_DOUBLE) { + r->throttle.delay = Z_DVAL_P(zoption); + } + zval_ptr_dtor(&zoption); + } + if ((zoption = get_option(r->options, ZEND_STRL("throttleChunk") TSRMLS_CC))) { + if (Z_TYPE_P(zoption) == IS_LONG) { + r->throttle.chunk = Z_LVAL_P(zoption); + } + zval_ptr_dtor(&zoption); + } + if (r->range.status == PHP_HTTP_RANGE_OK) { if (zend_hash_num_elements(&r->range.values) == 1) { /* single range */ @@ -869,10 +883,8 @@ PHP_METHOD(HttpEnvResponse, setThrottleRate) double delay = 1; if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|d", &chunk_size, &delay)) { - long chunk_size_long = (long) chunk_size; - set_option(getThis(), ZEND_STRL("throttleDelay"), IS_DOUBLE, &delay, 0 TSRMLS_CC); - set_option(getThis(), ZEND_STRL("throttleChunk"), IS_LONG, &chunk_size_long, 0 TSRMLS_CC); + set_option(getThis(), ZEND_STRL("throttleChunk"), IS_LONG, &chunk_size, 0 TSRMLS_CC); RETURN_TRUE; } RETURN_FALSE;