/usr/share/doc/libghc-happstack-server-doc/html/src/Happstack-Server-Cookie.html is in libghc-happstack-server-doc 7.4.6.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>src/Happstack/Server/Cookie.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE DeriveDataTypeable, FlexibleContexts #-}</span>
<a name="line-2"></a><span class='hs-comment'>-- | Functions for creating, adding, and expiring cookies. To lookup cookie values see "Happstack.Server.RqData".</span>
<a name="line-3"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Happstack</span><span class='hs-varop'>.</span><span class='hs-conid'>Server</span><span class='hs-varop'>.</span><span class='hs-conid'>Cookie</span>
<a name="line-4"></a> <span class='hs-layout'>(</span> <span class='hs-conid'>Cookie</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-5"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>CookieLife</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-6"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>mkCookie</span>
<a name="line-7"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>addCookie</span>
<a name="line-8"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>addCookies</span>
<a name="line-9"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>expireCookie</span>
<a name="line-10"></a> <span class='hs-layout'>)</span>
<a name="line-11"></a> <span class='hs-keyword'>where</span>
<a name="line-12"></a>
<a name="line-13"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span><span class='hs-varop'>.</span><span class='hs-conid'>Trans</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-14"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Happstack</span><span class='hs-varop'>.</span><span class='hs-conid'>Server</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span><span class='hs-varop'>.</span><span class='hs-conid'>Monads</span> <span class='hs-layout'>(</span><span class='hs-conid'>FilterMonad</span><span class='hs-layout'>,</span> <span class='hs-varid'>composeFilter</span><span class='hs-layout'>)</span>
<a name="line-15"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Happstack</span><span class='hs-varop'>.</span><span class='hs-conid'>Server</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span><span class='hs-varop'>.</span><span class='hs-conid'>Cookie</span> <span class='hs-layout'>(</span><span class='hs-conid'>Cookie</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>CookieLife</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>calcLife</span><span class='hs-layout'>,</span> <span class='hs-varid'>mkCookie</span><span class='hs-layout'>,</span> <span class='hs-varid'>mkCookieHeader</span><span class='hs-layout'>)</span>
<a name="line-16"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Happstack</span><span class='hs-varop'>.</span><span class='hs-conid'>Server</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span> <span class='hs-layout'>(</span><span class='hs-conid'>Response</span><span class='hs-layout'>,</span> <span class='hs-varid'>addHeader</span><span class='hs-layout'>)</span>
<a name="line-17"></a>
<a name="line-18"></a><a name="addCookie"></a><span class='hs-comment'>-- | Add the 'Cookie' to 'Response'.</span>
<a name="line-19"></a><span class='hs-comment'>--</span>
<a name="line-20"></a><span class='hs-comment'>-- example</span>
<a name="line-21"></a><span class='hs-comment'>-- </span>
<a name="line-22"></a><span class='hs-comment'>-- > main = simpleHTTP nullConf $</span>
<a name="line-23"></a><span class='hs-comment'>-- > do addCookie Session (mkCookie "name" "value")</span>
<a name="line-24"></a><span class='hs-comment'>-- > ok $ "You now have a session cookie."</span>
<a name="line-25"></a><span class='hs-comment'>--</span>
<a name="line-26"></a><span class='hs-comment'>-- see also: 'addCookies'</span>
<a name="line-27"></a><span class='hs-definition'>addCookie</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span> <span class='hs-varid'>m</span><span class='hs-layout'>,</span> <span class='hs-conid'>FilterMonad</span> <span class='hs-conid'>Response</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>CookieLife</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Cookie</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span>
<a name="line-28"></a><span class='hs-definition'>addCookie</span> <span class='hs-varid'>life</span> <span class='hs-varid'>cookie</span> <span class='hs-keyglyph'>=</span>
<a name="line-29"></a> <span class='hs-keyword'>do</span> <span class='hs-varid'>l</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>liftIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>calcLife</span> <span class='hs-varid'>life</span>
<a name="line-30"></a> <span class='hs-layout'>(</span><span class='hs-varid'>addHeaderM</span> <span class='hs-str'>"Set-Cookie"</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-varid'>mkCookieHeader</span> <span class='hs-varid'>l</span> <span class='hs-varid'>cookie</span>
<a name="line-31"></a> <span class='hs-keyword'>where</span>
<a name="line-32"></a> <span class='hs-varid'>addHeaderM</span> <span class='hs-varid'>a</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>composeFilter</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>res</span><span class='hs-keyglyph'>-></span> <span class='hs-varid'>addHeader</span> <span class='hs-varid'>a</span> <span class='hs-varid'>v</span> <span class='hs-varid'>res</span>
<a name="line-33"></a>
<a name="line-34"></a><a name="addCookies"></a><span class='hs-comment'>-- | Add the list 'Cookie' to the 'Response'.</span>
<a name="line-35"></a><span class='hs-comment'>-- </span>
<a name="line-36"></a><span class='hs-comment'>-- see also: 'addCookie'</span>
<a name="line-37"></a><span class='hs-definition'>addCookies</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span> <span class='hs-varid'>m</span><span class='hs-layout'>,</span> <span class='hs-conid'>FilterMonad</span> <span class='hs-conid'>Response</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-keyglyph'>[</span><span class='hs-layout'>(</span><span class='hs-conid'>CookieLife</span><span class='hs-layout'>,</span> <span class='hs-conid'>Cookie</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span>
<a name="line-38"></a><span class='hs-definition'>addCookies</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>mapM_</span> <span class='hs-layout'>(</span><span class='hs-varid'>uncurry</span> <span class='hs-varid'>addCookie</span><span class='hs-layout'>)</span>
<a name="line-39"></a>
<a name="line-40"></a><span class='hs-comment'>-- | Expire the named cookie immediately and set the cookie value to @\"\"@</span>
<a name="line-41"></a><span class='hs-comment'>--</span>
<a name="line-42"></a><span class='hs-comment'>-- > main = simpleHTTP nullConf $</span>
<a name="line-43"></a><span class='hs-comment'>-- > do expireCookie "name"</span>
<a name="line-44"></a><span class='hs-comment'>-- > ok $ "The cookie has been expired."</span>
<a name="line-45"></a>
<a name="line-46"></a><a name="expireCookie"></a><span class='hs-definition'>expireCookie</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadIO</span> <span class='hs-varid'>m</span><span class='hs-layout'>,</span> <span class='hs-conid'>FilterMonad</span> <span class='hs-conid'>Response</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span>
<a name="line-47"></a><span class='hs-definition'>expireCookie</span> <span class='hs-varid'>name</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>addCookie</span> <span class='hs-conid'>Expired</span> <span class='hs-layout'>(</span><span class='hs-varid'>mkCookie</span> <span class='hs-varid'>name</span> <span class='hs-str'>""</span><span class='hs-layout'>)</span>
</pre></body>
</html>
|