implemented basic logic for readURL
This commit is contained in:
@@ -30,6 +30,8 @@ time.
|
||||
|
||||
-}
|
||||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Network.Gemini.Capsule.Internal (
|
||||
readURL,
|
||||
sendResponse
|
||||
@@ -37,14 +39,24 @@ module Network.Gemini.Capsule.Internal (
|
||||
|
||||
import Data.Connection (Connection)
|
||||
|
||||
import Network.Gemini.Capsule.Encoding
|
||||
import Network.Gemini.Capsule.Types
|
||||
|
||||
-- Constants
|
||||
|
||||
-- Maximum size to read from a conneciton
|
||||
inBufSize :: Int
|
||||
inBufSize = 1026
|
||||
|
||||
-- | Reads a 'GemURL' from a 'Connection'
|
||||
readURL
|
||||
:: Connection a
|
||||
-- ^ the connection
|
||||
-> IO (Maybe GemURL)
|
||||
readURL = undefined
|
||||
readURL conn =
|
||||
strFromConn inBufSize conn >>= \case
|
||||
Nothing -> return Nothing
|
||||
Just str -> return $ decodeGemURL str
|
||||
|
||||
-- | Sends a 'GemResponse' to a 'Connection'
|
||||
sendResponse
|
||||
@@ -55,4 +67,15 @@ sendResponse
|
||||
-> IO ()
|
||||
sendResponse = undefined
|
||||
|
||||
-- | Reads up to a maxumum number of bytes from a 'Connection', UTF-8
|
||||
-- decodes it, and returns the resulting string (if possible) without
|
||||
-- the trailing CR/LF
|
||||
strFromConn
|
||||
:: Int
|
||||
-- ^ The maximum number of bytes to read
|
||||
-> Connection a
|
||||
-- ^ The connection to read from
|
||||
-> IO (Maybe String)
|
||||
strFromConn = undefined
|
||||
|
||||
--jl
|
||||
|
||||
Reference in New Issue
Block a user