HTTP-4000年1月2日: A library for client-side HTTP

Portabilitynon-portable (not tested)
Stabilityexperimental
MaintainerSigbjorn Finne <sigbjorn.finne@gmail.com>

Network.TCP

Description

Some utility functions for working with the Haskell network package. Mostly for internal use by the Network.HTTP code, but

Documentation

data Connection Source

The Connection newtype is a wrapper that allows us to make connections an instance of the Stream class, without GHC extensions. While this looks sort of like a generic reference to the transport layer it is actually TCP specific, which can be seen in the implementation of the 'Stream Connection' instance.

Instances

openTCPPort :: String -> Int -> IO Connection Source

openTCPPort uri port establishes a connection to a remote host, using getHostByName which possibly queries the DNS system, hence may trigger a network connection.

isConnectedTo :: Connection -> String -> IO Bool Source

Checks both that the underlying Socket is connected and that the connection peer matches the given host name (which is recorded locally).

openTCPConnection :: BufferType ty => String -> Int -> IO (HandleStream ty)Source

socketConnection :: BufferType ty => String -> Socket -> IO (HandleStream ty)Source

socketConnection, like openConnection but using a pre-existing Socket .

isTCPConnectedTo :: HandleStream ty -> String -> IO Bool Source

data HandleStream a Source

class BufferType bufType => HStream bufType whereSource

HStream overloads the use of HandleStream s, letting you overload the handle operations over the type that is communicated across the handle. It comes in handy for Network.HTTP Request and Responses as the payload representation isn't fixed, but overloaded.

The library comes with instances for ByteStrings and String, but should you want to plug in your own payload representation, defining your own HStream instance _should_ be all that it takes.

Methods

openStream :: String -> Int -> IO (HandleStream bufType)Source

openSocketStream :: String -> Socket -> IO (HandleStream bufType)Source

readLine :: HandleStream bufType -> IO (Result bufType)Source

readBlock :: HandleStream bufType -> Int -> IO (Result bufType)Source

writeBlock :: HandleStream bufType -> bufType -> IO (Result ())Source

close :: HandleStream bufType -> IO () Source

closeQuick :: HandleStream bufType -> IO () Source

closeOnEnd :: HandleStream bufType -> Bool -> IO () Source

Instances

data StreamHooks ty Source

Constructors

Fields

hook_readLine :: (ty -> String) -> Result ty -> IO ()
hook_readBlock :: (ty -> String) -> Int -> Result ty -> IO ()
hook_writeBlock :: (ty -> String) -> ty -> Result () -> IO ()
hook_close :: IO ()
hook_name :: String

Instances

Eq ty => Eq (StreamHooks ty)

nullHooks :: StreamHooks tySource

setStreamHooks :: HandleStream ty -> StreamHooks ty -> IO () Source

getStreamHooks :: HandleStream ty -> IO (Maybe (StreamHooks ty))Source

hstreamToConnection :: HandleStream String -> Connection Source

AltStyle によって変換されたページ (->オリジナル) /