File: urlparser008.phpt

package info (click to toggle)
php-pecl-http 3.1.0%2B2.6.0-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,060 kB
  • ctags: 3,725
  • sloc: ansic: 37,486; xml: 818; php: 635; pascal: 164; makefile: 2
file content (76 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download | duplicates (9)
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
--TEST--
url parser ipv6
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";

$urls = array(
	"s://[a:80",
	"s://[0]",
	"s://[::1]:80",
	"s://mike@[0:0:0:0:0:FFFF:204.152.189.116]/foo",
);

foreach ($urls as $url) {
	try {
		printf("\n%s\n", $url);
		var_dump(new http\Url($url, null, 0));
	} catch (Exception $e) {
		echo $e->getMessage(),"\n";
	}
}
?>
DONE
--EXPECTF--
Test

s://[a:80
http\Url::__construct(): Failed to parse hostinfo; expected ']' at pos 5 in '[a:80'

s://[0]
http\Url::__construct(): Failed to parse hostinfo; unexpected '[' at pos 0 in '[0]'

s://[::1]:80
object(http\Url)#%d (8) {
  ["scheme"]=>
  string(1) "s"
  ["user"]=>
  NULL
  ["pass"]=>
  NULL
  ["host"]=>
  string(5) "[::1]"
  ["port"]=>
  int(80)
  ["path"]=>
  NULL
  ["query"]=>
  NULL
  ["fragment"]=>
  NULL
}

s://mike@[0:0:0:0:0:FFFF:204.152.189.116]/foo
object(http\Url)#%d (8) {
  ["scheme"]=>
  string(1) "s"
  ["user"]=>
  string(4) "mike"
  ["pass"]=>
  NULL
  ["host"]=>
  string(24) "[::ffff:204.152.189.116]"
  ["port"]=>
  NULL
  ["path"]=>
  string(4) "/foo"
  ["query"]=>
  NULL
  ["fragment"]=>
  NULL
}
DONE