- ditch leak when throwing exceptions
[m6w6/ext-http] / tests / exceptions.phpt
1 --TEST--
2 exceptions
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkver(5);
7 ?>
8 --FILE--
9 <?php
10 echo "-TEST\n";
11
12 ini_set('http.only_exceptions', true);
13
14 $e = array(
15 HTTP_E_RUNTIME => 'Runtime',
16 HTTP_E_INVALID_PARAM => 'InvalidParam',
17 HTTP_E_HEADER => 'Header',
18 HTTP_E_MALFORMED_HEADERS => 'MalformedHeaders',
19 HTTP_E_REQUEST_METHOD => 'RequestMethod',
20 HTTP_E_MESSAGE_TYPE => 'MessageType',
21 HTTP_E_ENCODING => 'Encoding',
22 HTTP_E_REQUEST => 'Request',
23 HTTP_E_REQUEST_POOL => 'RequestPool',
24 HTTP_E_SOCKET => 'Socket',
25 HTTP_E_RESPONSE => 'Response',
26 HTTP_E_URL => 'Url',
27 );
28
29 foreach ($e as $i => $c) {
30 try {
31 $n = "Http{$c}Exception";
32 throw new $n;
33 } catch (HttpException $x) {
34 printf("%2d: %s\n", $i, get_class($x));
35 }
36 }
37 try {
38 $tmp = http_get(null);
39 } catch (HttpRequestException $x) {
40 printf("%s (%d)\n", $x->getMessage(), $x->getCode());
41 }
42 echo "Done\n";
43 ?>
44 --EXPECTF--
45 %sTEST
46 1: HttpRuntimeException
47 2: HttpInvalidParamException
48 3: HttpHeaderException
49 4: HttpMalformedHeadersException
50 5: HttpRequestMethodException
51 6: HttpMessageTypeException
52 7: HttpEncodingException
53 8: HttpRequestException
54 9: HttpRequestPoolException
55 10: HttpSocketException
56 11: HttpResponseException
57 12: HttpUrlException
58 Could not perform request: URL using bad/illegal format or missing URL (8)
59 Done