X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_response_object.c;h=9193590266ebbf31cd116c6d8189bffd1e1f05e6;hp=8be3efd7e988f1dc9308576d7b00df8e5bc2255c;hb=4c47eabee60a0266f3f27bf91528830b32da842e;hpb=dd579c42c06ebfe26ea2ff8ee6106a22d27e3340 diff --git a/http_response_object.c b/http_response_object.c index 8be3efd..9193590 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -214,10 +214,11 @@ zend_function_entry http_response_object_fe[] = { EMPTY_FUNCTION_ENTRY }; -void _http_response_object_init(INIT_FUNC_ARGS) +PHP_MINIT_FUNCTION(http_response_object) { HTTP_REGISTER_CLASS(HttpResponse, http_response_object, NULL, 0); http_response_object_declare_default_properties(); + return SUCCESS; } static inline void _http_response_object_declare_default_properties(TSRMLS_D) @@ -839,6 +840,7 @@ PHP_METHOD(HttpResponse, getBufferSize) */ PHP_METHOD(HttpResponse, setData) { + char *etag; zval *the_data; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &the_data)) { @@ -853,15 +855,10 @@ PHP_METHOD(HttpResponse, setData) RETURN_FALSE; } - if (!(Z_LVAL_P(convert_to_type_ex(IS_LONG, GET_STATIC_PROP(lastModified))) > 0)) { - UPD_STATIC_PROP(long, lastModified, http_last_modified(the_data, SEND_DATA)); - } - if (!Z_STRLEN_P(convert_to_type_ex(IS_STRING, GET_STATIC_PROP(eTag)))) { - char *etag = http_etag(Z_STRVAL_P(the_data), Z_STRLEN_P(the_data), SEND_DATA); - if (etag) { - UPD_STATIC_PROP(string, eTag, etag); - efree(etag); - } + UPD_STATIC_PROP(long, lastModified, http_last_modified(the_data, SEND_DATA)); + if (etag = http_etag(Z_STRVAL_P(the_data), Z_STRLEN_P(the_data), SEND_DATA)) { + UPD_STATIC_PROP(string, eTag, etag); + efree(etag); } RETURN_TRUE; @@ -897,6 +894,7 @@ PHP_METHOD(HttpResponse, getData) */ PHP_METHOD(HttpResponse, setStream) { + char *etag; zval *the_stream; php_stream *the_real_stream; php_stream_statbuf ssb; @@ -916,15 +914,10 @@ PHP_METHOD(HttpResponse, setStream) } zend_list_addref(Z_LVAL_P(the_stream)); - if (!(Z_LVAL_P(convert_to_type_ex(IS_LONG, GET_STATIC_PROP(lastModified))) > 0)) { - UPD_STATIC_PROP(long, lastModified, http_last_modified(the_real_stream, SEND_RSRC)); - } - if (!Z_STRLEN_P(convert_to_type_ex(IS_STRING, GET_STATIC_PROP(eTag)))) { - char *etag = http_etag(the_real_stream, 0, SEND_RSRC); - if (etag) { - UPD_STATIC_PROP(string, eTag, etag); - efree(etag); - } + UPD_STATIC_PROP(long, lastModified, http_last_modified(the_real_stream, SEND_RSRC)); + if (etag = http_etag(the_real_stream, 0, SEND_RSRC)) { + UPD_STATIC_PROP(string, eTag, etag); + efree(etag); } RETURN_TRUE; @@ -957,7 +950,7 @@ PHP_METHOD(HttpResponse, getStream) */ PHP_METHOD(HttpResponse, setFile) { - char *the_file; + char *the_file, *etag; int file_len; php_stream_statbuf ssb; @@ -974,15 +967,10 @@ PHP_METHOD(HttpResponse, setFile) RETURN_FALSE; } - if (!(Z_LVAL_P(convert_to_type_ex(IS_LONG, GET_STATIC_PROP(lastModified))) > 0)) { - UPD_STATIC_PROP(long, lastModified, http_last_modified(the_file, -1)); - } - if (!Z_STRLEN_P(convert_to_type_ex(IS_STRING, GET_STATIC_PROP(eTag)))) { - char *etag = http_etag(the_file, 0, -1); - if (etag) { - UPD_STATIC_PROP(string, eTag, etag); - efree(etag); - } + UPD_STATIC_PROP(long, lastModified, http_last_modified(the_file, -1)); + if (etag = http_etag(the_file, 0, -1)) { + UPD_STATIC_PROP(string, eTag, etag); + efree(etag); } RETURN_TRUE;