+++ /dev/null
---TEST--
-phpinfo
---SKIPIF--
-<?php
-include "skipif.inc";
-?>
---FILE--
-<?php
-echo "Test\n";
-phpinfo(INFO_MODULES);
-?>
-Done
---EXPECTF--
-Test
-%a
-HTTP Support => enabled
-Extension Version => 2.%s
-%a
-Done
--- /dev/null
+--TEST--
+invalid HTTP info
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+try {
+ var_dump(new http\Message("GET HTTP/1.1"));
+} catch (Exception $e) {
+ echo $e, "\n";
+}
+try {
+ var_dump(new http\Message("GET HTTP/1.123"));
+} catch (Exception $e) {
+ echo $e, "\n";
+}
+try {
+ var_dump(new http\Message("GETHTTP/1.1"));
+} catch (Exception $e) {
+ echo $e, "\n";
+}
+var_dump(new http\Message("GET / HTTP/1.1"));
+?>
+DONE
+--EXPECTF--
+exception 'http\Exception\BadMessageException' with message 'Could not parse message: GET HTTP/1.1' in %s
+Stack trace:
+#0 %s: http\Message->__construct('GET HTTP/1.1')
+#1 {main}
+exception 'http\Exception\BadMessageException' with message 'Could not parse message: GET HTTP/1.123' in %s
+Stack trace:
+#0 %s: http\Message->__construct('GET HTTP/1.123')
+#1 {main}
+exception 'http\Exception\BadMessageException' with message 'Could not parse message: GETHTTP/1.1' in %s
+Stack trace:
+#0 %s: http\Message->__construct('GETHTTP/1.1')
+#1 {main}
+object(http\Message)#%d (9) {
+ ["type":protected]=>
+ int(1)
+ ["body":protected]=>
+ NULL
+ ["requestMethod":protected]=>
+ string(3) "GET"
+ ["requestUrl":protected]=>
+ string(1) "/"
+ ["responseStatus":protected]=>
+ string(0) ""
+ ["responseCode":protected]=>
+ int(0)
+ ["httpVersion":protected]=>
+ string(3) "1.1"
+ ["headers":protected]=>
+ array(0) {
+ }
+ ["parentMessage":protected]=>
+ NULL
+}
+DONE
--- /dev/null
+--TEST--
+invalid HTTP info
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+echo "Test\n";
+
+function trap(callable $cb) {
+ try {
+ $cb();
+ } catch (Exception $e) {
+ echo $e,"\n";
+ }
+}
+
+trap(function() {
+ echo new http\Message("HTTP/1.1 99 Apples in my Basket");
+});
+
+trap(function() {
+ echo new http\Message("CONNECT HTTP/1.1");
+});
+
+echo new http\Message("HTTP/1.1");
+echo new http\Message("CONNECT www.example.org:80 HTTP/1.1");
+
+?>
+===DONE===
+--EXPECTF--
+Test
+exception 'http\Exception\BadMessageException' with message 'Could not parse message: HTTP/1.1 99 Apples in my ' in %sinfo002.php:%d
+Stack trace:
+#0 %sinfo002.php(%d): http\Message->__construct('HTTP/1.1 99 App...')
+#1 %sinfo002.php(%d): {closure}()
+#2 %sinfo002.php(%d): trap(Object(Closure))
+#3 {main}
+exception 'http\Exception\BadMessageException' with message 'Could not parse message: CONNECT HTTP/1.1' in %sinfo002.php:%d
+Stack trace:
+#0 %sinfo002.php(%d): http\Message->__construct('CONNECT HTTP/1....')
+#1 %sinfo002.php(%d): {closure}()
+#2 %sinfo002.php(%d): trap(Object(Closure))
+#3 {main}
+HTTP/1.1 200
+CONNECT www.example.org:80 HTTP/1.1
+===DONE===
+++ /dev/null
---TEST--
-invalid HTTP info
---SKIPIF--
-<?php include "skipif.inc"; ?>
---FILE--
-<?php
-
-try {
- var_dump(new http\Message("GET HTTP/1.1"));
-} catch (Exception $e) {
- echo $e, "\n";
-}
-try {
- var_dump(new http\Message("GET HTTP/1.123"));
-} catch (Exception $e) {
- echo $e, "\n";
-}
-try {
- var_dump(new http\Message("GETHTTP/1.1"));
-} catch (Exception $e) {
- echo $e, "\n";
-}
-var_dump(new http\Message("GET / HTTP/1.1"));
-?>
-DONE
---EXPECTF--
-exception 'http\Exception\BadMessageException' with message 'Could not parse message: GET HTTP/1.1' in %s
-Stack trace:
-#0 %s: http\Message->__construct('GET HTTP/1.1')
-#1 {main}
-exception 'http\Exception\BadMessageException' with message 'Could not parse message: GET HTTP/1.123' in %s
-Stack trace:
-#0 %s: http\Message->__construct('GET HTTP/1.123')
-#1 {main}
-exception 'http\Exception\BadMessageException' with message 'Could not parse message: GETHTTP/1.1' in %s
-Stack trace:
-#0 %s: http\Message->__construct('GETHTTP/1.1')
-#1 {main}
-object(http\Message)#%d (9) {
- ["type":protected]=>
- int(1)
- ["body":protected]=>
- NULL
- ["requestMethod":protected]=>
- string(3) "GET"
- ["requestUrl":protected]=>
- string(1) "/"
- ["responseStatus":protected]=>
- string(0) ""
- ["responseCode":protected]=>
- int(0)
- ["httpVersion":protected]=>
- string(3) "1.1"
- ["headers":protected]=>
- array(0) {
- }
- ["parentMessage":protected]=>
- NULL
-}
-DONE
--- /dev/null
+--TEST--
+phpinfo
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+phpinfo(INFO_MODULES);
+?>
+Done
+--EXPECTF--
+Test
+%a
+HTTP Support => enabled
+Extension Version => 2.%s
+%a
+Done