DCL_STATIC_PROP_N(PROTECTED, contentDisposition);
DCL_STATIC_PROP(PROTECTED, long, bufferSize, HTTP_SENDBUF_SIZE);
DCL_STATIC_PROP(PROTECTED, double, throttleDelay, 0.0);
+
+ DCL_STATIC_PROP(PUBLIC, string, dummy, "EMPTY");
}
/* ### USERLAND ### */
SET_STATIC_PROP(data, the_data);
ZVAL_LONG(GET_STATIC_PROP(lastModified), http_last_modified(the_data, SEND_DATA));
ZVAL_LONG(GET_STATIC_PROP(mode), SEND_DATA);
+ if (!Z_STRLEN_P(GET_STATIC_PROP(eTag))) {
+ SET_STATIC_PROP_STRING(eTag, http_etag(Z_STRVAL_P(the_data), Z_STRLEN_P(the_data), SEND_DATA), 0);
+ }
+
RETURN_TRUE;
}
/* }}} */
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &the_stream)) {
RETURN_FALSE;
}
+ zend_list_addref(Z_LVAL_P(the_stream));
+ php_stream_from_zval(the_real_stream, &the_stream);
USE_STATIC_PROP();
- php_stream_from_zval(the_real_stream, &the_stream);
ZVAL_LONG(GET_STATIC_PROP(stream), Z_LVAL_P(the_stream));
ZVAL_LONG(GET_STATIC_PROP(lastModified), http_last_modified(the_real_stream, SEND_RSRC));
ZVAL_LONG(GET_STATIC_PROP(mode), SEND_RSRC);
+ if (!Z_STRLEN_P(GET_STATIC_PROP(eTag))) {
+ SET_STATIC_PROP_STRING(eTag, http_etag(the_real_stream, 0, SEND_RSRC), 0);
+ }
+
RETURN_TRUE;
}
/* }}} */
SET_STATIC_PROP(file, the_file);
ZVAL_LONG(GET_STATIC_PROP(lastModified), http_last_modified(the_file, -1));
ZVAL_LONG(GET_STATIC_PROP(mode), -1);
+ if (!Z_STRLEN_P(GET_STATIC_PROP(eTag))) {
+ SET_STATIC_PROP_STRING(eTag, http_etag(the_file, 0, -1), 0);
+ }
RETURN_TRUE;
}
/* {{{ proto bool HttpResponse::send([bool clean_ob = true])
*
* Finally send the entity.
+ *
+ * Example:
+ * <pre>
+ * <?php
+ * HttpResponse::setCache(true);
+ * HttpResponse::setContentType('application/pdf');
+ * HttpResponse::setContentDisposition("$user.pdf", false);
+ * HttpResponse::setFile('sheet.pdf');
+ * HttpResponse::send();
+ * ?>
+ * </pre>
*/
PHP_METHOD(HttpResponse, send)
{
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean_ob)) {
RETURN_FALSE;
}
+ if (SG(headers_sent)) {
+ http_error(E_WARNING, HTTP_E_HEADER, "Cannot send HttpResponse, headers have already been sent");
+ RETURN_FALSE;
+ }
if (clean_ob) {
/* interrupt on-the-fly etag generation */
/* gzip */
if (Z_LVAL_P(GET_STATIC_PROP(gzip))) {
- php_start_ob_buffer_named("ob_gzhandler", 0, 1 TSRMLS_CC);
+ php_start_ob_buffer_named("ob_gzhandler", 0, 0 TSRMLS_CC);
} else {
php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC);
}
} else {
char *ctypes = INI_STR("default_mimetype");
size_t ctlen = ctypes ? strlen(ctypes) : 0;
-
+
if (ctlen) {
http_send_content_type(ctypes, ctlen);
} else {
{
php_stream *the_real_stream;
zval *the_stream = GET_STATIC_PROP(stream);
+ the_stream->type = IS_RESOURCE;
php_stream_from_zval(the_real_stream, &the_stream);
RETURN_SUCCESS(http_send_stream(the_real_stream));
}