git.iko.soy/typeable/servant-reflex
on master help sign in
fix XhrPayload datatype bug: do not incorrectly assume all data is utf8 encoded text
commit595d1ec348d995e2e4db89e8d159e027ed323608 authorJohannes Gerer <oss@johannesgerer.com> dateMon 17 Feb 2020, 18:32 (7 years ago) parent71c5440
1 file changed+4−3
src/Servant/Common/Req.hs+4−3
src/Servant/Common/Req.hs+4−3
@@ -19,6 +19,7 @@ import Control.Monad.IO.Class (MonadIO, liftIO)
1919import Data.Bifunctor (first)
2020import qualified Data.ByteString.Builder as Builder
2121import qualified Data.ByteString.Lazy.Char8 as BL
22+import Data.ByteString (ByteString)
2223import qualified Data.Map as Map
2324import Data.Maybe (catMaybes, fromMaybe)
2425import Data.Functor.Compose
@@ -244,7 +245,7 @@ reqToReflexRequest reqMeth reqHost req =
244245 , _xhrRequestConfig_user = Nothing
245246 , _xhrRequestConfig_password = Nothing
246247 , _xhrRequestConfig_responseType = Just XhrResponseType_ArrayBuffer
247− , _xhrRequestConfig_sendData = ""
248+ , _xhrRequestConfig_sendData = mempty
248249 , _xhrRequestConfig_withCredentials = False
249250 }
250251 Just rBody -> liftA2 mkConfigBody xhrHeaders rBody
@@ -335,9 +336,9 @@ performSomeRequestsAsync' opts newXhr req = performEventAsync $ ffor req $ \hrs
335336
336337
337338
338−type XhrPayload = T.Text
339+type XhrPayload = ByteString
339340bytesToPayload :: BL.ByteString -> XhrPayload
340−bytesToPayload = TE.decodeUtf8 . BL.toStrict
341+bytesToPayload = BL.toStrict
341342
342343
343344performRequestsCT