- fixed memory corruption
authorMichael Wallner <mike@php.net>
Fri, 7 Oct 2005 10:52:50 +0000 (10:52 +0000)
committerMichael Wallner <mike@php.net>
Fri, 7 Oct 2005 10:52:50 +0000 (10:52 +0000)
- added 4 etag mode tests

http_send_api.c
tests/etag_mode_001.phpt [new file with mode: 0644]
tests/etag_mode_002.phpt [new file with mode: 0644]
tests/etag_mode_003.phpt [new file with mode: 0644]
tests/etag_mode_004.phpt [new file with mode: 0644]

index 49c0aeda06407d0153eabd6f4fbcb3b19b72024b..f22a3d1fd398fb2a3e75ee46ff926accb5523659 100644 (file)
@@ -388,7 +388,7 @@ PHP_HTTP_API STATUS _http_send_ex(const void *data_ptr, size_t data_size, http_s
                if (etag = http_etag(data_ptr, data_size, data_mode)) {
                        char *sent_header = NULL;
                        
-                       http_send_etag_ex(etag, 32, &sent_header);
+                       http_send_etag_ex(etag, strlen(etag), &sent_header);
                        if (http_match_etag("HTTP_IF_NONE_MATCH", etag)) {
                                return http_exit_ex(304, sent_header, NULL, 0);
                        } else {
diff --git a/tests/etag_mode_001.phpt b/tests/etag_mode_001.phpt
new file mode 100644 (file)
index 0000000..19223a4
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+crc32 etag
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkcgi();
+?>
+--FILE--
+<?php
+ini_set('http.etag_mode', HTTP_ETAG_CRC32);
+http_cache_etag();
+http_send_data("abc\n");
+?>
+--EXPECTF--
+Content-type: %s
+X-Powered-By: PHP/%s
+Cache-Control: private, must-revalidate, max-age=0
+Accept-Ranges: bytes
+ETag: "28ad514e"
+Content-Length: 4
+
+abc
diff --git a/tests/etag_mode_002.phpt b/tests/etag_mode_002.phpt
new file mode 100644 (file)
index 0000000..229b22d
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+sha1 etag
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkcgi();
+?>
+--FILE--
+<?php
+ini_set('http.etag_mode', HTTP_ETAG_SHA1);
+http_cache_etag();
+http_send_data("abc\n");
+?>
+--EXPECTF--
+Content-type: %s
+X-Powered-By: PHP/%s
+Cache-Control: private, must-revalidate, max-age=0
+Accept-Ranges: bytes
+ETag: "03cfd743661f07975fa2f1220c5194cbaff48451"
+Content-Length: 4
+
+abc
diff --git a/tests/etag_mode_003.phpt b/tests/etag_mode_003.phpt
new file mode 100644 (file)
index 0000000..76abcfc
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+md5 etag
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkcgi();
+?>
+--FILE--
+<?php
+ini_set('http.etag_mode', HTTP_ETAG_MD5);
+http_cache_etag();
+http_send_data("abc\n");
+?>
+--EXPECTF--
+Content-type: %s
+X-Powered-By: PHP/%s
+Cache-Control: private, must-revalidate, max-age=0
+Accept-Ranges: bytes
+ETag: "0bee89b07a248e27c83fc3d5951213c1"
+Content-Length: 4
+
+abc
diff --git a/tests/etag_mode_004.phpt b/tests/etag_mode_004.phpt
new file mode 100644 (file)
index 0000000..571933e
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+mhash etag
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkcgi();
+?>
+--FILE--
+<?php
+ini_set('http.etag_mode', HTTP_ETAG_MHASH_WHIRLPOOL);
+http_cache_etag();
+http_send_data("abc\n");
+?>
+--EXPECTF--
+Content-type: %s
+X-Powered-By: PHP/%s
+Cache-Control: private, must-revalidate, max-age=0
+Accept-Ranges: bytes
+ETag: "53efa9e423f86dabd449b3e23dd0350def661b9e7055b23ceb2230c8b61bc0766514957ea9d349a88ef794715a1a17a409b549edfd6f43d696e63407fff3541c"
+Content-Length: 4
+
+abc