From 4906052864a06bd1fb104d65e2c494fdba5c165e Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Sat, 23 Jul 2022 20:40:24 +1200 Subject: [PATCH] Treat GET form submissions as normal fetch requests. --- src/Network/URI/Fetch.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Network/URI/Fetch.hs b/src/Network/URI/Fetch.hs index a243ab9..ca4f941 100644 --- a/src/Network/URI/Fetch.hs +++ b/src/Network/URI/Fetch.hs @@ -264,6 +264,8 @@ packQuery q "multipart/form-data" = HTTP.formDataBody $ Prelude.map encodePart q body <- B.readFile value return $ HTTP.RequestBodyBuilder size $ Builder.lazyByteString body packQuery _ _ = return -- Do not upload data if requested to do so in an invalid format. +submitURL' session mimes uri method "GET" query = fetchURL' session mimes uri { + uriQuery = '?': encodeQuery query } -- Specialcase GET! submitURL' session accept uri method encoding query | uriScheme uri `elem` ["http:", "https:"] = do -- HURL is very strict on when it allows cookies to be set: Only POST HTTP requests are considered consent. -- For the sake of most webframeworks' CSRF protection, cookies from retrieving the form are retroactively set. @@ -276,7 +278,7 @@ submitURL' session accept uri method encoding query | uriScheme uri `elem` ["htt return ret { HTTP.cookieJar = firstJust csrfCookies $ HTTP.cookieJar req, HTTP.method = method - }) $ \resp -> if method /= "POST" then return () else do + }) $ \resp -> do let cookies = HTTP.responseCookieJar resp swapMVar (globalCookieJar session) cookies writeCookies (cookiesPath session) cookies False -- 2.30.2