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;
if (zend_hash_num_elements(&r->range.values) == 1) {
zval **range, **begin, **end;
- if (SUCCESS != zend_hash_index_find(&r->range.values, 0, (void *) &range)
- || SUCCESS != zend_hash_index_find(Z_ARRVAL_PP(range), 0, (void *) &begin)
- || SUCCESS != zend_hash_index_find(Z_ARRVAL_PP(range), 1, (void *) &end)
+ if ( 1 == php_http_array_list(&r->range.values TSRMLS_CC, 1, &range)
+ && 2 == php_http_array_list(Z_ARRVAL_PP(range) TSRMLS_CC, 2, &begin, &end)
) {
+ ret = php_http_env_set_response_header_format(206, 1 TSRMLS_CC, "Content-Range: bytes %ld-%ld/%zu", Z_LVAL_PP(begin), Z_LVAL_PP(end), r->content.length);
+ } else {
/* this should never happen */
zend_hash_destroy(&r->range.values);
php_http_env_set_response_code(500 TSRMLS_CC);
ret = FAILURE;
- } else {
- ret = php_http_env_set_response_header_format(206, 1 TSRMLS_CC, "Content-Range: bytes %ld-%ld/%zu", Z_LVAL_PP(begin), Z_LVAL_PP(end), r->content.length);
}
} else {
php_http_boundary(r->range.boundary, sizeof(r->range.boundary) TSRMLS_CC);
php_http_buffer_init(&buf);
if (php_http_params_to_string(&buf, Z_ARRVAL_P(zoption_copy), ZEND_STRL(","), ZEND_STRL(";"), ZEND_STRL("="), PHP_HTTP_PARAMS_DEFAULT TSRMLS_CC)) {
- ret = php_http_env_set_response_header_format(0, 1 TSRMLS_CC, "Content-Disposition: %s", PHP_HTTP_BUFFER_VAL(&buf));
+ ret = php_http_env_set_response_header_format(0, 1 TSRMLS_CC, "Content-Disposition: %s", buf.data);
}
php_http_buffer_dtor(&buf);
zval_ptr_dtor(&zoption_copy);
+ zval_ptr_dtor(&zoption);
}
if (ret != SUCCESS) {
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) {
) {
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 */
zval **range, **begin, **end;
- if (SUCCESS != zend_hash_index_find(&r->range.values, 0, (void *) &range)
- || SUCCESS != zend_hash_index_find(Z_ARRVAL_PP(range), 0, (void *) &begin)
- || SUCCESS != zend_hash_index_find(Z_ARRVAL_PP(range), 1, (void *) &end)
+ if ( 1 == php_http_array_list(&r->range.values TSRMLS_CC, 1, &range)
+ && 2 == php_http_array_list(Z_ARRVAL_PP(range) TSRMLS_CC, 2, &begin, &end)
) {
- /* this should never happen */
- zend_hash_destroy(&r->range.values);
- php_http_env_set_response_code(500 TSRMLS_CC);
- ret = FAILURE;
- } else {
/* send chunk */
php_http_message_body_to_callback(obj->body, (php_http_pass_callback_t) php_http_env_response_send_data, r, Z_LVAL_PP(begin), Z_LVAL_PP(end) - Z_LVAL_PP(begin) + 1);
php_http_env_response_send_done(r);
zend_hash_destroy(&r->range.values);
ret = SUCCESS;
+ } else {
+ fprintf(stderr, "wut?");
+ /* this should never happen */
+ zend_hash_destroy(&r->range.values);
+ php_http_env_set_response_code(500 TSRMLS_CC);
+ ret = FAILURE;
}
+
} else {
/* send multipart/byte-ranges message */
HashPosition pos;
FOREACH_HASH_VAL(pos, &r->range.values, chunk) {
zval **begin, **end;
- if (IS_ARRAY == Z_TYPE_PP(chunk)
- && SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(chunk), 0, (void *) &begin)
- && IS_LONG == Z_TYPE_PP(begin)
- && SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(chunk), 1, (void *) &end)
- && IS_LONG == Z_TYPE_PP(end)
- ) {
+ if (2 == php_http_array_list(Z_ARRVAL_PP(chunk) TSRMLS_CC, 2, &begin, &end)) {
php_http_buffer_appendf(r->buffer,
PHP_HTTP_CRLF
"--%s" PHP_HTTP_CRLF
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;