DAV-1.2: RFC 4918 WebDAV support

Safe Haskell | None
Language | Haskell98

Network.Protocol.HTTP.DAV

Synopsis

- newtype DAVT m a = DAVT {
  - runDAVT :: ExceptT String (StateT DAVContext m) a
  }
- evalDAVT :: MonadIO m => DAVURL -> DAVT m a -> m (Either String a)
- withDAVContext :: MonadIO m => DAVURL -> (DAVContext -> m a) -> m a
- runDAVContext :: MonadIO m => DAVContext -> DAVT m a -> m (Either String a, DAVContext)
- setCreds :: MonadIO m => ByteString -> ByteString -> DAVT m ()
- setDepth :: MonadIO m => Maybe Depth -> DAVT m ()
- setResponseTimeout :: MonadIO m => Maybe Int -> DAVT m ()
- setUserAgent :: MonadIO m => ByteString -> DAVT m ()
- data DAVContext = DAVContext {
  - _allowedMethods :: [ByteString]
  - _baseRequest :: Request
  - _basicusername :: ByteString
  - _basicpassword :: ByteString
  - _complianceClasses :: [ByteString]
  - _depth :: Maybe Depth
  - _httpManager :: Maybe Manager
  - _lockToken :: Maybe ByteString
  - _userAgent :: ByteString
  }
- caldavReportM :: MonadIO m => DAVT m Document
- delContentM :: MonadIO m => DAVT m ()
- getPropsM :: MonadIO m => DAVT m Document
- getContentM :: MonadIO m => DAVT m (Maybe ByteString, ByteString)
- withContentM :: MonadIO m => (Response BodyReader -> IO a) -> DAVT m a
- mkCol :: (MonadIO m, MonadBase IO m, MonadCatch m) => DAVT m Bool
- moveContentM :: MonadIO m => ByteString -> DAVT m ()
- putPropsM :: MonadIO m => Document -> DAVT m ()
- putContentM :: MonadIO m => (Maybe ByteString, ByteString) -> DAVT m ()
- putContentM' :: MonadIO m => (Maybe ByteString, RequestBody) -> DAVT m ()
- withLockIfPossible :: (MonadIO m, MonadBase IO m) => Bool -> DAVT m a -> DAVT m a
- withLockIfPossibleForDelete :: (MonadIO m, MonadBase IO m) => Bool -> DAVT m a -> DAVT m a
- inDAVLocation :: MonadIO m => (String -> String) -> DAVT m a -> DAVT m a
- getDAVLocation :: Monad m => DAVT m String
- mkDAVContext :: MonadIO m => DAVURL -> m DAVContext
- closeDAVContext :: MonadIO m => DAVContext -> m ()
- data Depth
  - = Depth0
  - | Depth1
  - | DepthInfinity
- data DAVContext = DAVContext {
  - _allowedMethods :: [ByteString]
  - _baseRequest :: Request
  - _basicusername :: ByteString
  - _basicpassword :: ByteString
  - _complianceClasses :: [ByteString]
  - _depth :: Maybe Depth
  - _httpManager :: Maybe Manager
  - _lockToken :: Maybe ByteString
  - _userAgent :: ByteString
  }
- userAgent :: Lens' DAVContext ByteString
- lockToken :: Lens' DAVContext (Maybe ByteString)
- httpManager :: Lens' DAVContext (Maybe Manager)
- depth :: Lens' DAVContext (Maybe Depth)
- complianceClasses :: Lens' DAVContext [ByteString]
- basicusername :: Lens' DAVContext ByteString
- basicpassword :: Lens' DAVContext ByteString
- baseRequest :: Lens' DAVContext Request
- allowedMethods :: Lens' DAVContext [ByteString]

# Documentation

newtype DAVT m a Source

Constructors

DAVT |

Fields

runDAVT :: ExceptT String (StateT DAVContext m) a

Instances

MonadTrans DAVT Source |
Monad m => MonadError String (DAVT m) Source |
Monad m => MonadState DAVContext (DAVT m) Source |
MonadBase b m => MonadBase b (DAVT m) Source |
Monad m => Monad (DAVT m) Source |
Functor m => Functor (DAVT m) Source |
MonadFix m => MonadFix (DAVT m) Source |
Monad m => Applicative (DAVT m) Source |
Monad m => Alternative (DAVT m) Source |
Monad m => MonadPlus (DAVT m) Source |
MonadThrow m => MonadThrow (DAVT m) Source |
MonadCatch m => MonadCatch (DAVT m) Source |
MonadIO m => MonadIO (DAVT m) Source |

evalDAVT :: MonadIO m => DAVURL -> DAVT m a -> m (Either String a) Source

withDAVContext :: MonadIO m => DAVURL -> (DAVContext -> m a) -> m a Source

runDAVContext :: MonadIO m => DAVContext -> DAVT m a -> m (Either String a, DAVContext) Source

setCreds :: MonadIO m => ByteString -> ByteString -> DAVT m () Source

setDepth :: MonadIO m => Maybe Depth -> DAVT m () Source

setResponseTimeout :: MonadIO m => Maybe Int -> DAVT m () Source

setUserAgent :: MonadIO m => ByteString -> DAVT m () Source

data DAVContext Source

Constructors

DAVContext |

Fields

_allowedMethods :: [ByteString]
_baseRequest :: Request
_basicusername :: ByteString
_basicpassword :: ByteString
_complianceClasses :: [ByteString]
_depth :: Maybe Depth
_httpManager :: Maybe Manager
_lockToken :: Maybe ByteString
_userAgent :: ByteString

Instances

Monad m => MonadState DAVContext (DAVT m) |

caldavReportM :: MonadIO m => DAVT m Document Source

delContentM :: MonadIO m => DAVT m () Source

getPropsM :: MonadIO m => DAVT m Document Source

getContentM :: MonadIO m => DAVT m (Maybe ByteString, ByteString) Source

Note that the entire request body is buffered in memory. To stream large files use withContentM instead.

withContentM :: MonadIO m => (Response BodyReader -> IO a) -> DAVT m a Source

mkCol :: (MonadIO m, MonadBase IO m, MonadCatch m) => DAVT m Bool Source

moveContentM :: MonadIO m => ByteString -> DAVT m () Source

putPropsM :: MonadIO m => Document -> DAVT m () Source

putContentM :: MonadIO m => (Maybe ByteString, ByteString) -> DAVT m () Source

Note that the entire request body is buffered in memory; not suitable for large files.

putContentM' :: MonadIO m => (Maybe ByteString, RequestBody) -> DAVT m () Source

To send a large file, pass eg a RequestBodyStream containing the file's content.

withLockIfPossible :: (MonadIO m, MonadBase IO m) => Bool -> DAVT m a -> DAVT m a Source

withLockIfPossibleForDelete :: (MonadIO m, MonadBase IO m) => Bool -> DAVT m a -> DAVT m a Source

inDAVLocation :: MonadIO m => (String -> String) -> DAVT m a -> DAVT m a Source

Normally, DAVT actions act on the url that is provided to eg, evalDAVT. Sometimes, it's useful to adjust the url that is acted on, while remaining in the same DAV session.

inLocation temporarily adjusts the url's path, while performing a DAVT action.

For example:

    import System.FilePath.Posix -- posix for url path manipulation

    mkColRecursive d = do
      let parent = takeDirectory d
      when (parent /= d) $
        mkColRecursive parent
      inDAVLocation (</> d) mkCol

Note that operations that modify the DAVContext (such as setCreds and setCreds) can be run inside davLocation, but will not have any effect on the calling DAVContext.

getDAVLocation :: Monad m => DAVT m String Source

Gets the path of the url that DAVT actions will act on.

mkDAVContext :: MonadIO m => DAVURL -> m DAVContext Source

closeDAVContext :: MonadIO m => DAVContext -> m () Source

Deprecated: deprecated because http-client deprecated closeManager

data Depth Source

Constructors

Depth0 |
Depth1 |
DepthInfinity |

Instances

Read Depth Source |
Show Depth Source |

data DAVContext Source

Constructors

DAVContext |

Fields

_allowedMethods :: [ByteString]
_baseRequest :: Request
_basicusername :: ByteString
_basicpassword :: ByteString
_complianceClasses :: [ByteString]
_depth :: Maybe Depth
_httpManager :: Maybe Manager
_lockToken :: Maybe ByteString
_userAgent :: ByteString

Instances

Monad m => MonadState DAVContext (DAVT m) |

userAgent :: Lens' DAVContext ByteString Source

lockToken :: Lens' DAVContext (Maybe ByteString) Source

httpManager :: Lens' DAVContext (Maybe Manager) Source

depth :: Lens' DAVContext (Maybe Depth) Source

complianceClasses :: Lens' DAVContext [ByteString] Source

basicusername :: Lens' DAVContext ByteString Source

basicpassword :: Lens' DAVContext ByteString Source

baseRequest :: Lens' DAVContext Request Source

allowedMethods :: Lens' DAVContext [ByteString] Source