release 1.7.6
[m6w6/ext-http] / tests / encodings.phpt
1 --TEST--
2 encodings
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 skipif(!function_exists('http_deflate'), 'need zlib');
7 ?>
8 --FILE--
9 <?php
10 echo "-TEST\n";
11
12 set_time_limit(0);
13 error_reporting(E_ALL);
14
15 $s = '';
16
17 for ($i = 0; $i < 5000; ++$i) {
18 $s .= chr(rand(0,255));
19 }
20
21 var_dump($s == http_inflate(http_deflate($s, HTTP_DEFLATE_TYPE_ZLIB)));
22 var_dump($s == http_inflate(http_deflate($s, HTTP_DEFLATE_TYPE_GZIP)));
23 var_dump($s == http_inflate(http_deflate($s, HTTP_DEFLATE_TYPE_RAW)));
24
25 if (extension_loaded('zlib')) {
26
27 $s = "A simple test string, which won't blow up ext/zlib.\n";
28
29 ($s == http_inflate(gzencode($s))) or print "GZIP Failed\n";
30 ($s == http_inflate(gzdeflate($s))) or print "DEFLATE Failed\n";
31 ($s == http_inflate(gzcompress($s))) or print "COMPRESS Failed\n";
32
33 ($s == gzinflate(http_deflate($s, HTTP_DEFLATE_TYPE_RAW))) or print "INFLATE Failed\n";
34 ($s == gzuncompress(http_deflate($s, HTTP_DEFLATE_TYPE_ZLIB))) or print "UNCOMPRESS Failed\n";
35 }
36
37 echo "Done\n";
38 ?>
39 --EXPECTF--
40 %aTEST
41 bool(true)
42 bool(true)
43 bool(true)
44 Done