From: Michael Wallner Date: Fri, 7 Oct 2005 16:32:44 +0000 (+0000) Subject: - add crc etag test X-Git-Tag: RELEASE_0_15_0~30 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=798fddb0eb9be9f784a0a93443ec8eb0aca82e61;p=m6w6%2Fext-http - add crc etag test - update etag and last-modified even if we had one, to reflect changes; the user must set custom ones after supplying the data then... --- diff --git a/http_response_object.c b/http_response_object.c index 8be3efd..72289b6 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -839,6 +839,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 +854,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 +893,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 +913,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 +949,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 +966,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; diff --git a/tests/etag_mode_001.phpt b/tests/etag_mode_001.phpt index 19223a4..d8cf594 100644 --- a/tests/etag_mode_001.phpt +++ b/tests/etag_mode_001.phpt @@ -16,7 +16,7 @@ Content-type: %s X-Powered-By: PHP/%s Cache-Control: private, must-revalidate, max-age=0 Accept-Ranges: bytes -ETag: "28ad514e" +ETag: "4e818847" Content-Length: 4 abc diff --git a/tests/etag_mode_011.phpt b/tests/etag_mode_011.phpt index 75505aa..06b35e1 100644 --- a/tests/etag_mode_011.phpt +++ b/tests/etag_mode_011.phpt @@ -15,6 +15,6 @@ print("abc\n"); Content-type: %s X-Powered-By: PHP/%s Cache-Control: private, must-revalidate, max-age=0 -ETag: "28ad514e" +ETag: "4e818847" abc diff --git a/tests/etag_mode_crc.phpt b/tests/etag_mode_crc.phpt new file mode 100644 index 0000000..2e83a9b --- /dev/null +++ b/tests/etag_mode_crc.phpt @@ -0,0 +1,37 @@ +--TEST-- +sane crc etags +--SKIPIF-- + +--FILE-- +