~alcinnz/hurl

4906052864a06bd1fb104d65e2c494fdba5c165e — Adrian Cochrane 2 years ago 12c81bf
Treat GET form submissions as normal fetch requests.
1 files changed, 3 insertions(+), 1 deletions(-)

M src/Network/URI/Fetch.hs
M src/Network/URI/Fetch.hs => src/Network/URI/Fetch.hs +3 -1
@@ 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