Skip to content

aschuhardt/Opal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Opal on Nuget Opal build Last commit MIT

Opal

A client library for the Gemini and Titan protocols targeting .NET Standard 2.0 and .NET 7

Features

  • Asynchronous requests
  • Typed Gemtext document handling
  • Event-based user input
  • Configurable redirect behavior
  • Optional client certificate support with creation and persistence
  • Optional TOFU semantics with persistent certificate caching
  • No external dependencies

Usage

Install the Nuget package

Install-Package Opal -Version 1.7.6

Create an instance of a client and make requests

// the default behavior is to automatically follow redirects and to persit 
// local and remote certificates to disk
var client = new OpalClient();

var response = await client.SendRequestAsync("gemini.circumlunar.space");

if (response is GemtextResponse gmi)
{
  // the response body may accessed directly...
  await using (var reader = new StreamReader(gmi.Body))
    Console.WriteLine(reader.ReadToEnd());
  
  // ... or as a collection of strongly-typed ILine objects
  foreach (var line in gmi.AsDocument())
  {
    if (line is LinkLine link)
      Console.WriteLine($"Found link to {link.Uri}");
     
    Console.WriteLine(line);
  }
}