Skip to content

Instantly share code, notes, and snippets.

View aycanirican's full-sized avatar
💭
Lifelong learning

Aycan iRiCAN aycanirican

💭
Lifelong learning
View GitHub Profile
c_sendfile :: Fd -> Fd -> COff -> CSize -> IO CSsize
#if defined(LINUX)
c_sendfile ofd ifd o c = do
alloca $ \off -> do
poke off o
r <- c_sendfile_linux ofd ifd off c
return r
#endif
req1 = B.concat
[ "GET /favicon.ico HTTP/1.1\r\n"
, "Host: 0.0.0.0=5000\r\n"
, "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\n"
, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
, "Accept-Language: en-us,en;q=0.5\r\n"
, "Accept-Encoding: gzip,deflate\r\n"
, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
, "Keep-Alive: 300\r\n"
, "Connection: keep-alive\r\n"
threadDelay :: Int -> IO () Source
Suspends the current thread for a given number of microseconds (GHC only).
There is no guarantee that the thread will be rescheduled promptly when the delay has expired, but the thread will ***never continue to run earlier than specified***.
---
module Main where
aycan@fgt:~/haskell/snap-server/test$ ./runTestsAndCoverage.sh
Snap.Internal.Http.Parser.Tests:
show: [OK]
parseCookie: [OK]
chunked transfer encoding: [OK, passed 1000 tests]
chunk . unchunk == id: [OK, passed 1000 tests]
pipelined chunk . unchunk == id: [Failed]
Falsifiable with seed -6342116022785088208, after 12 tests. Reason: Exception: 'control message: Just (Err "not enough bytes")'
testBothChunkedEmpty: [Failed]
ERROR: control message: Just (Err "not enough bytes")
aycan@fgt:~/haskell/snap-server/test$ ./runTestsAndCoverage.sh
Snap.Internal.Http.Parser.Tests:
show: [OK]
parseCookie: [OK]
chunked transfer encoding: [OK, passed 1000 tests]
chunk . unchunk == id: [OK, passed 1000 tests]
testBothChunkedBuffered1: [Failed]
Falsifiable with seed 8872790038128987215, after 2 tests. Reason: Exception: 'control message: Just (Err "not enough bytes")'
testBothChunkedBuffered2: [Failed]
Falsifiable with seed 932625037523277916, after 6 tests. Reason: Exception: 'control message: Just (Err "not enough bytes")'
pRequest' :: Parser IRequest
pRequest' = IRequest
<$> (option "" crlf *> pMethod) <* sp
<*> pUri <* sp
<*> pVersion <* crlf
<*> pHeaders <* crlf
{-# LANGUAGE OverloadedStrings #-}
module Session
( sessionCookie
, withSession
, newSessionCookie
, session
) where
import Control.Monad.Trans (liftIO)
import Control.Applicative
{-# LANGUAGE TemplateHaskell, TypeFamilies, DeriveDataTypeable,
FlexibleInstances, MultiParamTypeClasses, FlexibleContexts,
UndecidableInstances, TypeOperators
#-}
module App.ObjectStore
( objectStoreHandlers
) where
import Coretal.Services.OpenIDHandlers
-- import Happstack.Data
evTimerSetRepeat :: EvTimerPtr -> Double -> IO ()
evTimerSetRepeat p t = do
evtimer <- peek p
poke p evtimer { repeat = t }
-- | throw a timeout exception to the handling thread -- it'll clean up
-- everything
timerCallback :: EvLoopPtr -- ^ loop obj
-> EvTimerPtr -- ^ timer obj
-> IORef CTime -- ^ when to timeout?
-> MVar ThreadId -- ^ thread to kill
-> TimerCallback
timerCallback loop tmr ioref tmv _ _ _ = do
debug "Backend.timerCallback: entered"