+guessMIMEType ∷ LS.ByteString → MIMEType
+{-# INLINEABLE guessMIMEType #-}
+guessMIMEType = read
+ ∘ unsafePerformIO
+ ∘ flip BS.unsafeUseAsCStringLen (magicCString magic)
+ ∘ BS.concat
+ ∘ LS.toChunks
+ where
+ magic ∷ Magic
+ {-# NOINLINE magic #-}
+ magic = unsafePerformIO
+ $ do m ← magicOpen [MagicMime]
+ magicLoadDefault m
+ return m
+
+isSafeChar ∷ Char → Bool
+{-# INLINEABLE isSafeChar #-}
+isSafeChar c
+ | c ≡ '/' = True
+ | isReserved c = False
+ | c > ' ' ∧ c ≤ '~' = True
+ | otherwise = False
+
+mkQueryString ∷ [(Text, Text)] → ByteString
+{-# INLINEABLE mkQueryString #-}
+mkQueryString = BS.intercalate (C8.singleton ';') ∘ map encodePair
+ where
+ encodePair ∷ (Text, Text) → ByteString
+ {-# INLINE encodePair #-}
+ encodePair (k, v)
+ = BS.intercalate (C8.singleton '=') [encodeText k, encodeText v]
+
+ encodeText ∷ Text → ByteString
+ {-# INLINE encodeText #-}
+ encodeText = toURLEncoded ∘ encodeUtf8