| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Generates the output for absoluteURI-related tests
|
|
|
5 |
*
|
|
|
6 |
* This file is called by other phpt files to run the same tests on
|
|
|
7 |
* different $_ENV settings.
|
|
|
8 |
*
|
|
|
9 |
* @category HTTP
|
|
|
10 |
* @package HTTP
|
|
|
11 |
* @author Philippe Jausions <jausions@php.net>
|
|
|
12 |
* @version $Id: absoluteURI.inc,v 1.2 2008/02/09 07:46:32 jausions Exp $
|
|
|
13 |
*/
|
|
|
14 |
require_once 'HTTP.php';
|
|
|
15 |
|
|
|
16 |
// For 4th argument of HTTP::absoluteURI() method
|
|
|
17 |
if (!defined('HTTP_RELATIVETOSCRIPT')) {
|
|
|
18 |
define('HTTP_RELATIVETOSCRIPT', true);
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
$tests = array(
|
|
|
22 |
// page, protocol, port
|
|
|
23 |
array(null, null, null), // Current full URI
|
|
|
24 |
array('?new=value', null, null), // Append/replace query string
|
|
|
25 |
array('#anchor', null, null), // Anchor target to URI
|
|
|
26 |
array('/page.html', null, null), // Web root
|
|
|
27 |
array('page.html', null, null), // Relative
|
|
|
28 |
array('page.html', 'http', null), // Force HTTP
|
|
|
29 |
array('page.html', 'http', 80), // Force HTTP / default port
|
|
|
30 |
array('page.html', 'http', 8080), // Force HTTP / port 8080
|
|
|
31 |
array('page.html', 'https', null), // Force HTTPS
|
|
|
32 |
array('page.html', 'https', 443), // Force HTTPS / default port
|
|
|
33 |
array('page.html', null, 8080), // Switch port (same protocol)
|
|
|
34 |
array('page.html', 'https', 8888), // Force HTTPS / port 8888
|
|
|
35 |
);
|
|
|
36 |
|
|
|
37 |
foreach ($tests as $test) {
|
|
|
38 |
list($page, $protocol, $port) = $test;
|
|
|
39 |
|
|
|
40 |
echo sprintf('%-20s', implode('|', $test)).' => '
|
|
|
41 |
.HTTP::absoluteURI($page, $protocol, $port, HTTP_RELATIVETOSCRIPT)
|
|
|
42 |
."\n";
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
?>
|