1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
--TEST--
message reversal
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
use http\Message as HttpMessage;
function newHttpMessage($s) {
return new http\Message($s);
}
$s = "GET /first HTTP/1.1\nHTTP/1.1 200 Ok-first\nGET /second HTTP/1.1\nHTTP/1.1 200 Ok-second\nGET /third HTTP/1.1\nHTTP/1.1 200 Ok-third\n";
echo newHttpMessage($s)->toString(true);
echo "===\n";
echo newHttpMessage($s)->reverse()->toString(true);
$m = newHttpMessage($s);
$r = $m->reverse();
unset($m);
var_dump($r->count());
echo $r->toString(true);
?>
DONE
--EXPECTF--
GET /first HTTP/1.1
HTTP/1.1 200 Ok-first
GET /second HTTP/1.1
HTTP/1.1 200 Ok-second
GET /third HTTP/1.1
HTTP/1.1 200 Ok-third
===
HTTP/1.1 200 Ok-third
GET /third HTTP/1.1
HTTP/1.1 200 Ok-second
GET /second HTTP/1.1
HTTP/1.1 200 Ok-first
GET /first HTTP/1.1
int(6)
HTTP/1.1 200 Ok-third
GET /third HTTP/1.1
HTTP/1.1 200 Ok-second
GET /second HTTP/1.1
HTTP/1.1 200 Ok-first
GET /first HTTP/1.1
DONE
|