HTTP-4000.4.1: A library for client-side HTTP

Copyright | See LICENSE file
License | BSD
Maintainer | Ganesh Sittampalam <ganesh@earth.li>
Stability | experimental
Portability | non-portable (not tested)
Safe Haskell | Safe-Inferred
Language | Haskell98

Network.Stream

Description

An library for creating abstract streams. Originally part of Gray's/Bringert's HTTP module.

- Changes by Robin Bate Boerop robin@bateboerop.name:
- Removed unnecessary import statements.
- Moved Debug code to StreamDebugger.hs
- Moved Socket-related code to StreamSocket.hs.
- Changes by Simon Foster:
- Split Network.HTTPmodule up into to separate Network.[Stream,TCP,HTTP] modules

Synopsis

- class Stream x where
  - readLine :: x -> IO (Result String)
  - readBlock :: x -> Int -> IO (Result String)
  - writeBlock :: x -> String -> IO (Result ())
  - close :: x -> IO ()
  - closeOnEnd :: x -> Bool -> IO ()
- data ConnError
  - = ErrorReset
  - | ErrorClosed
  - | ErrorParse String
  - | ErrorMisc String
- type Result a = Either ConnError a
- bindE :: Result a -> (a -> Result b) -> Result b
- fmapE :: (a -> Result b) -> IO (Result a) -> IO (Result b)
- failParse :: String -> Result a
- failWith :: ConnError -> Result a
- failMisc :: String -> Result a

# Documentation

class Stream x where Source #

Streams should make layering of TLS protocol easier in future, they allow reading/writing to files etc for debugging, they allow use of protocols other than TCP/IP and they allow customisation.

Instances of this class should not trim the input in any way, e.g. leave LF on line endings etc. Unless that is exactly the behaviour you want from your twisted instances ;)

Methods

readLine :: x -> IO (Result String) Source #

readBlock :: x -> Int -> IO (Result String) Source #

writeBlock :: x -> String -> IO (Result ()) Source #

close :: x -> IO () Source #

closeOnEnd Source #

Arguments

:: x |
-> Bool |
-> IO () | True => shutdown the connection when response has been read / end-of-stream has been reached.

#### Instances

Instances details

Stream Connection Source # |
Instance details Defined in Network.TCP Methods readLine :: Connection -> IO (Result String) Source # readBlock :: Connection -> Int -> IO (Result String) Source # writeBlock :: Connection -> String -> IO (Result ()) Source # close :: Connection -> IO () Source # closeOnEnd :: Connection -> Bool -> IO () Source #
Stream Socket Source # |
Instance details Defined in Network.StreamSocket Methods readLine :: Socket -> IO (Result String) Source # readBlock :: Socket -> Int -> IO (Result String) Source # writeBlock :: Socket -> String -> IO (Result ()) Source # close :: Socket -> IO () Source # closeOnEnd :: Socket -> Bool -> IO () Source #
Stream x => Stream (StreamDebugger x) Source # |
Instance details Defined in Network.StreamDebugger Methods readLine :: StreamDebugger x -> IO (Result String) Source # readBlock :: StreamDebugger x -> Int -> IO (Result String) Source # writeBlock :: StreamDebugger x -> String -> IO (Result ()) Source # close :: StreamDebugger x -> IO () Source # closeOnEnd :: StreamDebugger x -> Bool -> IO () Source #

data ConnError Source #

Constructors

ErrorReset |
ErrorClosed |
ErrorParse String |
ErrorMisc String |

#### Instances

Instances details

Show ConnError Source # |
Instance details Defined in Network.Stream Methods showsPrec :: Int -> ConnError -> ShowS Source # show :: ConnError -> String Source # showList :: [ConnError] -> ShowS Source #
Eq ConnError Source # |
Instance details Defined in Network.Stream Methods (==) :: ConnError -> ConnError -> Bool Source # (/=) :: ConnError -> ConnError -> Bool Source #

type Result a = Either ConnError a Source #

This is the type returned by many exported network functions.

bindE :: Result a -> (a -> Result b) -> Result b Source #

fmapE :: (a -> Result b) -> IO (Result a) -> IO (Result b) Source #

failParse :: String -> Result a Source #

failWith :: ConnError -> Result a Source #

failMisc :: String -> Result a Source #