HTTP-4000.3.13: A library for client-side HTTP

CopyrightSee LICENSE file
LicenseBSD
MaintainerGanesh Sittampalam <ganesh@earth.li>
Stabilityexperimental
Portabilitynon-portable (not tested)
Safe HaskellNone
LanguageHaskell98

Network.TCP

Description

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

Synopsis

Documentation

data Connection #

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
Stream Connection # 
Instance details

Defined in Network.TCP

data EndPoint #

Constructors

EndPoint 

Fields

Instances
Eq EndPoint # 
Instance details

Defined in Network.TCP

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

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 -> EndPoint -> IO Bool #

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

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

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

class BufferType bufType => HStream bufType where #

HStream overloads the use of HandleStreams, 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) #

openSocketStream :: String -> Int -> Socket -> IO (HandleStream bufType) #

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

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

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

close :: HandleStream bufType -> IO () #

closeQuick :: HandleStream bufType -> IO () #

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

Instances
HStream String # 
Instance details

Defined in Network.TCP

HStream ByteString # 
Instance details

Defined in Network.TCP

HStream ByteString # 
Instance details

Defined in Network.TCP

data StreamHooks ty #

Constructors

StreamHooks 

Fields

Instances
Eq ty => Eq (StreamHooks ty) # 
Instance details

Defined in Network.TCP

Methods

(==) :: StreamHooks ty -> StreamHooks ty -> Bool #

(/=) :: StreamHooks ty -> StreamHooks ty -> Bool #