haskell-tor-0.1.1: A Haskell Tor Node

Safe HaskellNone
LanguageHaskell2010

Tor.NetworkStack.Fetch

Description

Automatic fetching and decoding of resources needed for Tor; specifically, this hides a lot of the HTTP GET cruft that would otherwise be sprinkled about the code.

Users should avoid using this module for long-term projects. It ended up both growing a little bit beyond what was intended, and also managed to be less generally useful than I had thought. Thus, I suspect this module will be overhauled in the not-too-distant future.

Synopsis

Documentation

data FetchItem Source

One of the things we can automatically fetch.

Instances

class Fetchable a Source

A set of types that are automatically fetchable by this subsystem.

Minimal complete definition

parseBlob

fetch :: Fetchable a => TorNetworkStack ls s -> String -> Word16 -> FetchItem -> IO (Either String a) Source

Fetch the given item from the given host and port, using the given network stack, returning either the error that occurred fetching that item or the item. The String used for the host will be directly passed to the network stack's connect function without further processing, so you should think about whether that means you need to address resolution or not.

readResponse :: TorNetworkStack ls s -> s -> IO (Either String ByteString) Source

Read the response to a GET request. This returns the parsed interior of a GET response, rather than the whole response, so one of the possible errors you might receive is an HTTP response parsing error.