@@ -197,10 +197,6 @@ module Network.HTTP.Req
197 , bsResponse
197 , bsResponse
198 , LbsResponse
198 , LbsResponse
199 , lbsResponse
199 , lbsResponse
204 -- ** Inspecting a response
200 -- ** Inspecting a response
205 , responseBody
201 , responseBody
206 , responseStatusCode
202 , responseStatusCode
@@ -250,9 +246,6 @@ import qualified Data.CaseInsensitive as CI
250import qualified Data.List.NonEmpty as NE
246import qualified Data.List.NonEmpty as NE
251import qualified Data.Text as T
247import qualified Data.Text as T
252import qualified Data.Text.Encoding as T
248import qualified Data.Text.Encoding as T
253−import qualified Data.Text.Encoding.Error as TE
254−import qualified Data.Text.Lazy as TL
255−import qualified Data.Text.Lazy.Encoding as TL
256import qualified Data.Text.Read as TR
249import qualified Data.Text.Read as TR
257import qualified Network.Connection as NC
250import qualified Network.Connection as NC
258import qualified Network.HTTP.Client as L
251import qualified Network.HTTP.Client as L
@@ -299,8 +292,6 @@ import GHC.Exts (Constraint)
299-- * 'jsonResponse'
292-- * 'jsonResponse'
300-- * 'bsResponse' (to get a strict 'ByteString')
293-- * 'bsResponse' (to get a strict 'ByteString')
301-- * 'lbsResponse' (to get a lazy 'BL.ByteString')
294-- * 'lbsResponse' (to get a lazy 'BL.ByteString')
302−-- * 'textResponse' (to get a strict 'Text', UTF-8 decoded)
303−-- * 'ltextResponse' (to get a lazy 'TL.Text', UTF-8 decoded)
305-- Finally, @options@ is a 'Monoid' that holds a composite 'Option' for all
296-- Finally, @options@ is a 'Monoid' that holds a composite 'Option' for all
306-- other optional settings like query parameters, headers, non-standard port
297-- other optional settings like query parameters, headers, non-standard port
@@ -1430,70 +1421,6 @@ instance HttpResponse LbsResponse where
1430lbsResponse :: Proxy LbsResponse
1421lbsResponse :: Proxy LbsResponse
1431lbsResponse = Proxy
1422lbsResponse = Proxy
1433−-- | Make a request and interpret the body of the response as strict 'Text'.
1434−-- The 'handleHttpException' method of 'MonadHttp' instance corresponding to
1435−-- monad in which you use 'req' will determine what to do in the case when
1436−-- decoding fails (the 'TextEncHttpException' constructor will be used).
1440−newtype TextResponse = TextResponse (L.Response Text)
1442−instance HttpResponse TextResponse where
1443− type HttpResponseBody TextResponse = Text
1444− toVanillaResponse (TextResponse r) = r
1445− getHttpResponse request manager = do
1446− r <- httpBs request manager
1447− let bs = L.responseBody r
1448− case T.decodeUtf8' bs of
1450− (throwIO . TextEncHttpException uexc . B.take bodyPreviewLength) bs
1451− Right txt -> return (TextResponse r { L.responseBody = txt })
1452− makeResponseBodyPreview =
1453− B.take bodyPreviewLength . T.encodeUtf8 . responseBody
1455−-- | Use this as the fourth argument of 'req' to specify that you want to
1456−-- interpret the response body as 'T.Text'.
1460−textResponse :: Proxy TextResponse
1461−textResponse = Proxy
1463−-- | Make a request and interpret the body of the response as lazy
1464−-- 'TL.Text'. The 'handleHttpException' method of 'MonadHttp' instance
1465−-- corresponding to monad in which you use 'req' will determine what to do
1466−-- in the case when decoding fails (the 'TextEncHttpException' constructor
1471−newtype LTextResponse = LTextResponse (L.Response TL.Text)
1473−instance HttpResponse LTextResponse where
1474− type HttpResponseBody LTextResponse = TL.Text
1475− toVanillaResponse (LTextResponse r) = r
1476− getHttpResponse request manager = do
1477− r <- L.httpLbs request manager
1478− case TL.decodeUtf8' (L.responseBody r) of
1479− Left uexc -> throwIO
1480− . TextEncHttpException uexc
1482− . BL.take bodyPreviewLength
1485− Right txt -> return (LTextResponse r { L.responseBody = txt })
1486− makeResponseBodyPreview =
1487− BL.toStrict . BL.take bodyPreviewLength . TL.encodeUtf8 . responseBody
1489−-- | Use this as the fourth argument of 'req' to specify that you want to
1490−-- interpret the response body as a lazy 'TL.Text'.
1494−ltextResponse :: Proxy LTextResponse
1495−ltextResponse = Proxy
1497-- | Perform a 'L.Request' using given 'L.Manager' and return the response
1424-- | Perform a 'L.Request' using given 'L.Manager' and return the response
1498-- as a strict 'ByteString'.
1425-- as a strict 'ByteString'.
@@ -1624,12 +1551,6 @@ data HttpException
1624 | JsonHttpException String
1551 | JsonHttpException String
1625 -- ^ A wrapper with Aeson-produced 'String' describing why decoding
1552 -- ^ A wrapper with Aeson-produced 'String' describing why decoding
1626 -- failed
1553 -- failed
1627− | TextEncHttpException TE.UnicodeException ByteString
1628− -- ^ This value indicates that a response that was expected to be in the
1629− -- UTF-8 encoding could not be decoded; the 'ByteString' is the
1630− -- beginning of response in raw binary form
1633 deriving (Show, Typeable, Generic)
1554 deriving (Show, Typeable, Generic)
1635instance Exception HttpException
1556instance Exception HttpException