-
-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathRequestFactory.host.phpt
More file actions
85 lines (72 loc) · 2 KB
/
RequestFactory.host.phpt
File metadata and controls
85 lines (72 loc) · 2 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* Test: Nette\Http\RequestFactory and host.
*/
use Nette\Http\RequestFactory,
Tester\Assert;
require __DIR__ . '/../bootstrap.php';
//$_SERVER = array(
// 'HTTP_HOST' => 'localhost',
//);
//$factory = new RequestFactory;
//Assert::same( 'http://localhost/', (string) $factory->createHttpRequest()->getUrl() );
//
//
//$_SERVER = array(
// 'HTTP_HOST' => 'www-x.nette.org',
//);
//$factory = new RequestFactory;
//Assert::same( 'http://www-x.nette.org/', (string) $factory->createHttpRequest()->getUrl() );
//
//
//$_SERVER = array(
// 'HTTP_HOST' => '192.168.0.1:8080',
//);
//$factory = new RequestFactory;
//Assert::same( 'http://192.168.0.1:8080/', (string) $factory->createHttpRequest()->getUrl() );
//
//
//$_SERVER = array(
// 'HTTP_HOST' => '[::1aF]:8080',
//);
//$factory = new RequestFactory;
//Assert::same( 'http://[::1af]:8080/', (string) $factory->createHttpRequest()->getUrl() );
//
//
//$_SERVER = array(
// 'HTTP_HOST' => "a.cz\n",
//);
//$factory = new RequestFactory;
//Assert::same( 'http:///', (string) $factory->createHttpRequest()->getUrl() );
//
//
//$_SERVER = array(
// 'HTTP_HOST' => 'AB',
//);
//$factory = new RequestFactory;
//Assert::same( 'http://ab/', (string) $factory->createHttpRequest()->getUrl() );
//
//$_SERVER = array(
// 'HTTP_HOST' => 'a' . str_repeat('.a', 4000000),
//);
//
//$time = -microtime(TRUE);
//$factory = new RequestFactory;
//$factory->createHttpRequest();
//$time += microtime(TRUE);
//Assert::true( $time < 1 );
//echo $time;
// Assert::same( 'http://ab/', (string) $factory->createHttpRequest()->getUrl() );
$_SERVER = [
'REQUEST_URI' => '/aaaaaaaaaaaaaaaaaaaaaaaaa.php/' . str_repeat('A', 1e6) . '?' . str_repeat('B', 1e6) . '=' . str_repeat('C', 1e6),
'SCRIPT_NAME' => '/aaaaaaaaaaaaaaaaaaaaaaaaa.php'
];
$factory = new RequestFactory;
$factory->createHttpRequest();
$time = -microtime(TRUE);
for ($i = 0; $i < 10; $i++) {
$factory = new RequestFactory;
$factory->createHttpRequest();
}
$time += microtime(TRUE);
printf("Time: %.2f ms\n", $time * 1e3);