Safe Haskell | None |
---|---|
Language | Haskell2010 |
Web.Cookie.Jar
Description
Parser
for a Netscape/Mozilla cookie jar
Provides:
- parsing functions that parse the Netscape/Mozilla cookie jar file
that provide an incomplete roundtrip with the parser.Builder
s- incomplete because some of the fields in
Cookie
are not saved in the Netscape/Mozilla cookie jar; seecookieBuilder
.
- incomplete because some of the fields in
- combinators to ease use with Network.Http.Client, like
usingCookiesFromFile'
, e.g,
persistCookies :: Manager -> FilePath -> Request -> IO (Response a) persistCookies manager cookieJarPath req = do let httpLbs' = usingCookiesFromFile' cookiePath $ flip httpLbs manager httpLbs' req
Synopsis
- writeJar :: FilePath -> CookieJar -> IO ()
- writeJar' :: Builder -> FilePath -> CookieJar -> IO ()
- writeNetscapeJar :: FilePath -> CookieJar -> IO ()
- readJar :: FilePath -> IO (Either String CookieJar)
- readJarX :: FilePath -> IO CookieJar
- data BadJarFile = InvalidJar
- addCookiesFromFile :: FilePath -> Request -> IO Request
- saveCookies :: FilePath -> Response a -> Request -> IO (Response a)
- usingCookiesFromFile :: FilePath -> Request -> (Request -> IO (Response b)) -> IO (Response b)
- usingCookiesFromFile' :: FilePath -> (Request -> IO (Response b)) -> Request -> IO (Response b)
- cookieJarParser :: Parser CookieJar
- cookieParser :: Parser Cookie
- parseCookieJar :: ByteString -> Either String CookieJar
- netscapeJarBuilder :: CookieJar -> Builder
- jarBuilder :: CookieJar -> Builder
- jarBuilder' :: Builder -> CookieJar -> Builder
- cookieBuilder :: Cookie -> Builder
- parseOnly :: Parser a -> ByteString -> Either String a
read and write files
writeJar :: FilePath -> CookieJar -> IO () Source #
Writes a cookie jar to the given path in the Netscape/Mozilla format, with no header
writeJar' :: Builder -> FilePath -> CookieJar -> IO () Source #
Like writeJar
, but outputs a header before the cookie lines
writeNetscapeJar :: FilePath -> CookieJar -> IO () Source #
Like writeJar
, but outputs the Netscape header before the cookie lines
readJarX :: FilePath -> IO CookieJar Source #
Like readJar
, but throws BadJarFile
in IO
if the read fails
data BadJarFile Source #
Reasons a jar file could not be loaded
Constructors
InvalidJar |
Instances
Exception BadJarFile Source # | |
Defined in Web.Cookie.Jar Methods toException :: BadJarFile -> SomeException # fromException :: SomeException -> Maybe BadJarFile # displayException :: BadJarFile -> String # | |
Show BadJarFile Source # | |
Defined in Web.Cookie.Jar Methods showsPrec :: Int -> BadJarFile -> ShowS # show :: BadJarFile -> String # showList :: [BadJarFile] -> ShowS # | |
Eq BadJarFile Source # | |
Defined in Web.Cookie.Jar |
use with http-client
Add any appropriate Cookies from a cookie file to a Request
- if the file is absent, no update occurs
- throws
BadJarFile
if the file can't be parsed
saveCookies :: FilePath -> Response a -> Request -> IO (Response a) Source #
Update the cookie file with any cookies in the response
When the file does not exist, it's created as long as the parent directory exists and permits the file to be written
The output is saved to the cookie file using writeJar
throws an exception if:
- cannot write due to permissions or parent directory not existing
- the file exists, but cannot be parsed into Cookies
usingCookiesFromFile :: FilePath -> Request -> (Request -> IO (Response b)) -> IO (Response b) Source #
Perform a HTTP request first loading then saving any matching cookies from a cookie file
usingCookiesFromFile' :: FilePath -> (Request -> IO (Response b)) -> Request -> IO (Response b) Source #
usingCookiesFromFile
with arguments re-ordered
Cookie jar format
parsing
cookieJarParser :: Parser CookieJar Source #
Parser
for a cookie jar in the Netscape/Mozilla format
cookieParser :: Parser Cookie Source #
parseCookieJar :: ByteString -> Either String CookieJar Source #
Parse a ByteString
containing a cookie jar in the Netscape/Mozilla format
printing
netscapeJarBuilder :: CookieJar -> Builder Source #
Like jarBuilder
but outputs the Netscape header before the cookie lines
jarBuilder :: CookieJar -> Builder Source #
Print a cookie jar in the Netscape/Mozilla format, with no header
jarBuilder' :: Builder -> CookieJar -> Builder Source #
Like jarBuilder
but outputs a header before the cookie lines
cookieBuilder :: Cookie -> Builder Source #
Builder for one cookie; generates a single line in the Cookie Jar file format
the values of the following fields are not output, as the file format does support them.
cookie_creation_time
cookie_last_access_time
cookie_persistent
re-exports
parseOnly :: Parser a -> ByteString -> Either String a #