diff options
author | Craig Andrews <candrews@integralblue.com> | 2009-12-04 18:44:26 -0500 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2009-12-04 18:44:26 -0500 |
commit | aab7344002fd390e5b62a3eb82f3a418fd294617 (patch) | |
tree | b214e7d4b3e9f0ca9818fea9e3d9efa0249c00c6 /plugins/Minify/extlib/minify/min_unit_tests/HTTP_ConditionalGet/4.php | |
parent | 1fd7e5e3794621993b01a5833faa8b6fa26c3847 (diff) | |
parent | 01b089d9be046db1253cb3bb90e8635b50fddd84 (diff) |
Merge branch 'minify' into 0.9.x
Diffstat (limited to 'plugins/Minify/extlib/minify/min_unit_tests/HTTP_ConditionalGet/4.php')
-rw-r--r-- | plugins/Minify/extlib/minify/min_unit_tests/HTTP_ConditionalGet/4.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/Minify/extlib/minify/min_unit_tests/HTTP_ConditionalGet/4.php b/plugins/Minify/extlib/minify/min_unit_tests/HTTP_ConditionalGet/4.php new file mode 100644 index 000000000..4b77d2084 --- /dev/null +++ b/plugins/Minify/extlib/minify/min_unit_tests/HTTP_ConditionalGet/4.php @@ -0,0 +1,49 @@ +<?php + +set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib')); +require 'HTTP/ConditionalGet.php'; + +// emulate regularly updating document +$every = 20; +$lastModified = round(time()/$every)*$every - $every; + +require 'HTTP/Encoder.php'; +list($enc,) = HTTP_Encoder::getAcceptedEncoding(); + +$cg = new HTTP_ConditionalGet(array( + 'lastModifiedTime' => $lastModified + ,'encoding' => $enc +)); +$cg->sendHeaders(); +if ($cg->cacheIsValid) { + // we're done + exit(); +} + +// output encoded content + +$title = 'ConditionalGet + Encoder'; +$explain = ' +<p>Using ConditionalGet and Encoder is straightforward. First impliment the +ConditionalGet, then if the cache is not valid, encode and send the content</p> +<p>This script emulates a document that changes every ' .$every. ' seconds. +<br>This is version: ' . date('r', $lastModified) . '</p> +'; +require '_include.php'; +$content = get_content(array( + 'title' => $title + ,'explain' => $explain +)); + +$he = new HTTP_Encoder(array( + 'content' => get_content(array( + 'title' => $title + ,'explain' => $explain + )) +)); +$he->encode(); + +// usually you would just $he->sendAll(), but here we want to emulate slow +// connection +$he->sendHeaders(); +send_slowly($he->getContent()); |