git.iko.soy/typeable/servant-reflex
on master help sign in
Merge pull request #59 from hamishmack/master
1761f87Greg Hale
src/Servant/Common/Req.hs+8−8
@@ -223,7 +223,7 @@ reqToReflexRequest reqMeth reqHost req =
223 Map.insert "Content-Type" bCT (Map.fromList hs)
223 Map.insert "Content-Type" bCT (Map.fromList hs)
224 , _xhrRequestConfig_user = Nothing
224 , _xhrRequestConfig_user = Nothing
225 , _xhrRequestConfig_password = Nothing
225 , _xhrRequestConfig_password = Nothing
226− , _xhrRequestConfig_responseType = Nothing
226+ , _xhrRequestConfig_responseType = Just XhrResponseType_ArrayBuffer
227 , _xhrRequestConfig_withCredentials = False
227 , _xhrRequestConfig_withCredentials = False
228 , _xhrRequestConfig_responseHeaders = def
228 , _xhrRequestConfig_responseHeaders = def
229 }
229 }
@@ -235,7 +235,7 @@ reqToReflexRequest reqMeth reqHost req =
235 Right hs -> Right $ def { _xhrRequestConfig_headers = Map.fromList hs
235 Right hs -> Right $ def { _xhrRequestConfig_headers = Map.fromList hs
236 , _xhrRequestConfig_user = Nothing
236 , _xhrRequestConfig_user = Nothing
237 , _xhrRequestConfig_password = Nothing
237 , _xhrRequestConfig_password = Nothing
238− , _xhrRequestConfig_responseType = Nothing
238+ , _xhrRequestConfig_responseType = Just XhrResponseType_ArrayBuffer
239 , _xhrRequestConfig_sendData = ""
239 , _xhrRequestConfig_sendData = ""
240 , _xhrRequestConfig_withCredentials = False
240 , _xhrRequestConfig_withCredentials = False
241 }
241 }
@@ -344,15 +344,15 @@ performRequestsCT
344 -> m (Event t (f (ReqResult tag a)))
344 -> m (Event t (f (ReqResult tag a)))
345performRequestsCT ct reqMeth reqs reqHost opts trigger = do
345performRequestsCT ct reqMeth reqs reqHost opts trigger = do
346 resps <- performRequests reqMeth reqs reqHost opts trigger
346 resps <- performRequests reqMeth reqs reqHost opts trigger
347+ let decodeResp (Just (XhrResponseBody_ArrayBuffer x)) =
347− let decodeResp x = first T.pack .
348+ first T.pack .
348− mimeUnrender ct .
349+ mimeUnrender ct $
349− BL.fromStrict .
350+ BL.fromStrict x
350− TE.encodeUtf8 =<< note "No body text"
351+ decodeResp _ = Left "No body"
351− (_xhrResponse_responseText x)
352 return $ fmap
352 return $ fmap
353 (\(t,rs) -> ffor rs $ \r -> case r of
353 (\(t,rs) -> ffor rs $ \r -> case r of
354 Left e -> RequestFailure t e
354 Left e -> RequestFailure t e
355− Right g -> evalResponse decodeResp (t,g)
355+ Right g -> evalResponse (decodeResp . _xhrResponse_response) (t,g)
356 )
356 )
357 resps
357 resps
358
358