aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/react/socket/examples/22-http-client.php
diff options
context:
space:
mode:
authormarvin-borner@live.com2018-04-16 21:09:05 +0200
committermarvin-borner@live.com2018-04-16 21:09:05 +0200
commitcf14306c2b3f82a81f8d56669a71633b4d4b5fce (patch)
tree86700651aa180026e89a66064b0364b1e4346f3f /assets/php/vendor/react/socket/examples/22-http-client.php
parent619b01b3615458c4ed78bfaeabb6b1a47cc8ad8b (diff)
Main merge to user management system - files are now at /main/public/
Diffstat (limited to 'assets/php/vendor/react/socket/examples/22-http-client.php')
-rwxr-xr-xassets/php/vendor/react/socket/examples/22-http-client.php60
1 files changed, 0 insertions, 60 deletions
diff --git a/assets/php/vendor/react/socket/examples/22-http-client.php b/assets/php/vendor/react/socket/examples/22-http-client.php
deleted file mode 100755
index fcb8107..0000000
--- a/assets/php/vendor/react/socket/examples/22-http-client.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-// Simple plaintext HTTP and secure HTTPS client example (for illustration purposes only).
-// This shows how an URI parameter can parsed to decide whether to establish
-// a plaintext TCP/IP or secure TLS connection and then send an
-// application level protocol message (HTTP).
-// Real applications should use react/http-client instead!
-//
-// Unlike examples #11 and #12, this example will actually take an optional URI
-// parameter and parse it to connect to the correct default port and use the
-// correct transport protocol.
-//
-// $ php examples/22-http-client.php
-// $ php examples/22-http-client.php https://reactphp.org/
-
-use React\EventLoop\Factory;
-use React\Socket\ConnectionInterface;
-use React\Socket\Connector;
-use React\Stream\WritableResourceStream;
-
-require __DIR__ . '/../vendor/autoload.php';
-
-$uri = isset($argv[1]) ? $argv[1] : 'www.google.com';
-
-if (strpos($uri, '://') === false) {
- $uri = 'http://' . $uri;
-}
-$parts = parse_url($uri);
-
-if (!$parts || !isset($parts['scheme'], $parts['host'])) {
- fwrite(STDERR, 'Usage error: required argument <host:port>' . PHP_EOL);
- exit(1);
-}
-
-$loop = Factory::create();
-$connector = new Connector($loop);
-
-if (!isset($parts['port'])) {
- $parts['port'] = $parts['scheme'] === 'https' ? 443 : 80;
-}
-
-$host = $parts['host'];
-if (($parts['scheme'] === 'http' && $parts['port'] !== 80) || ($parts['scheme'] === 'https' && $parts['port'] !== 443)) {
- $host .= ':' . $parts['port'];
-}
-$target = ($parts['scheme'] === 'https' ? 'tls' : 'tcp') . '://' . $parts['host'] . ':' . $parts['port'];
-$resource = isset($parts['path']) ? $parts['path'] : '/';
-if (isset($parts['query'])) {
- $resource .= '?' . $parts['query'];
-}
-
-$stdout = new WritableResourceStream(STDOUT, $loop);
-
-$connector->connect($target)->then(function (ConnectionInterface $connection) use ($resource, $host, $stdout) {
- $connection->pipe($stdout);
-
- $connection->write("GET $resource HTTP/1.0\r\nHost: $host\r\n\r\n");
-}, 'printf');
-
-$loop->run();