~alcinnz/hurl

c535223ff3507bd46c6599cedc62b852ac34338d — Adrian Cochrane 2 years ago aedc142
Correctly report error MIMEtypes.
1 files changed, 4 insertions(+), 4 deletions(-)

M src/Network/URI/Fetch.hs
M src/Network/URI/Fetch.hs => src/Network/URI/Fetch.hs +4 -4
@@ 419,7 419,7 @@ fetchURL' sess@Session { connCtxt = ctxt } mimes uri@URI {
                fetchURL' sess {
                    redirectCount = redirectCount sess - 1
                } mimes $ relativeTo redirect' uri
            (x, y, err) -> return (uri, mimeERR, Left $ Txt.pack $
            (x, y, err) -> return (uri, htmlERR, Left $ Txt.pack $
                trans' sess $ GeminiError x y $ Txt.unpack $
                    Txt.replace "<" "&lt;" $ Txt.replace "&" "&amp;" err)
    where


@@ 557,7 557,7 @@ fetchHTTPCached session @ Session { trans' = t} shouldCache
                        Just location <- lookup "location" $ HTTP.responseHeaders response,
                        Just uri' <- parseURIReference $ C8.unpack location ->
                    return $ Left $ relativeTo uri' uri
                (Status code msg, "", _) -> return $ Right (Txt.pack mimeERR,
                (Status code msg, "", _) -> return $ Right (Txt.pack htmlERR,
                    B.fromStrict $ C8.pack $
                        trans' session $ HTTPStatus code $ C8.unpack msg)
                (_, body, (mimetype:_)) -> do


@@ 575,9 575,9 @@ fetchHTTPCached session @ Session { trans' = t} shouldCache
        Right (mime, body) ->
            let mime' = L.map (Txt.unpack . Txt.strip) $ Txt.splitOn ";" mime
            in return $ resolveCharset' uri mime' body
  `catch` \e -> do return (rawUri, mimeERR, Left $ Txt.pack $ transHttp t e)
  `catch` \e -> do return (rawUri, htmlERR, Left $ Txt.pack $ transHttp t e)
fetchHTTPCached session _ [] uri _ _ =
    return (uri, mimeERR, Left $ Txt.pack $ trans' session $ UnsupportedMIME "")
    return (uri, htmlERR, Left $ Txt.pack $ trans' session $ UnsupportedMIME "")
#endif

#if WITH_HTTP_URI || WITH_GEMINI_URI