From 6df3d321d9b67c4541f50158b087d37c4b22e886 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 12 Nov 2023 11:16:56 +0100 Subject: initial commit --- src/Client.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Client.php (limited to 'src/Client.php') diff --git a/src/Client.php b/src/Client.php new file mode 100644 index 0000000..255e29f --- /dev/null +++ b/src/Client.php @@ -0,0 +1,40 @@ +baseUrl = $baseUrl; + } + + public function request($url): Response + { + $context = stream_context_create(options: [ + 'ssl' => [ + 'verify_peer' => false, + ], + ]); + + $connection = stream_socket_client( + address: "tls://{$this->baseUrl}:1965", + context: $context + ); + + fwrite($connection, "gemini://{$this->baseUrl}{$url}"); + $responseString = ''; + while (!feof($connection)) { + $responseString .= fgets($connection, 1024); + } + fclose($connection); + + $response = Response::fromString($responseString); + + return $response; + } +} -- cgit v1.2.3