mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-08-29 03:28:42 +00:00
replace ERROR SYNTAX 7 with ERROR SIZE for bad message body size
This commit is contained in:
@@ -34,3 +34,8 @@ newConnection rKey =
|
||||
senderKey = Nothing,
|
||||
status = ConnActive
|
||||
}
|
||||
|
||||
-- class MonadMsgStore s m where
|
||||
-- addMsg :: s -> SenderId -> MsgBody -> m (Either ErrorType ())
|
||||
-- getMsg :: s -> RecipientId -> m (Either ErrorType Message)
|
||||
-- delMsg :: s -> RecipientId -> m (Either ErrorType ())
|
||||
|
||||
+1
-4
@@ -123,7 +123,7 @@ type Timestamp = Encoded
|
||||
|
||||
type MsgBody = B.ByteString
|
||||
|
||||
data ErrorType = UNKNOWN | PROHIBITED | SYNTAX Int | AUTH | INTERNAL deriving (Show, Eq)
|
||||
data ErrorType = UNKNOWN | PROHIBITED | SYNTAX Int | SIZE | AUTH | INTERNAL deriving (Show, Eq)
|
||||
|
||||
errBadParameters :: Int
|
||||
errBadParameters = 2
|
||||
@@ -139,6 +139,3 @@ errNoConnectionId = 5
|
||||
|
||||
errMessageBody :: Int
|
||||
errMessageBody = 6
|
||||
|
||||
errMessageBodySize :: Int
|
||||
errMessageBodySize = 7
|
||||
|
||||
+1
-1
@@ -152,5 +152,5 @@ tGet fromParty h = do
|
||||
Just size -> do
|
||||
body <- getBytes h size
|
||||
s <- getLn h
|
||||
return if null s then Right body else Left $ SYNTAX errMessageBodySize
|
||||
return if null s then Right body else Left SIZE
|
||||
Nothing -> return . Left $ SYNTAX errMessageBody
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ syntaxTests = do
|
||||
it "many parameters" $ [("123", "1", "SEND 11 hello")] >#> [("", "1", "ERROR SYNTAX 2")]
|
||||
it "no connection ID" $ [("123", "", "SEND :hello")] >#> [("", "", "ERROR SYNTAX 5")]
|
||||
it "bad message body" $ [("123", "1", "SEND hello")] >#> [("", "1", "ERROR SYNTAX 6")]
|
||||
it "bigger body" $ [("123", "1", "SEND 4\nhello\n")] >#> [("", "1", "ERROR SYNTAX 7")]
|
||||
it "bigger body" $ [("123", "1", "SEND 4\nhello\n")] >#> [("", "1", "ERROR SIZE")]
|
||||
describe "broker response not allowed" do
|
||||
it "OK" $ [("123", "1", "OK")] >#> [("", "1", "ERROR PROHIBITED")]
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user