X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_response_object.c;h=5ca8edd70fdb8f75a0039125f6efc1e517c43f36;hb=f6280c0f47b07d5c6079f7074491b6173c89599f;hp=a172c5d3c47b0e74c2db10ef0437b4857407703e;hpb=8853addaa76d93fd058345ecfef9bd0d1a53c4ec;p=m6w6%2Fext-http diff --git a/http_response_object.c b/http_response_object.c index a172c5d..5ca8edd 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -511,6 +511,7 @@ PHP_METHOD(HttpResponse, setStream) 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(); @@ -591,6 +592,10 @@ 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 */ @@ -669,6 +674,7 @@ PHP_METHOD(HttpResponse, send) { 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)); }