<commit_before>{-# LANGUAGE OverloadedStrings #-}
module Network.Wai.Middleware.MethodOverride
    ( methodOverride
    ) where

import Network.Wai
import Control.Monad (join)

-- | Allows overriding of the HTTP request method via the _method query string
-- parameter.
methodOverride :: Middleware
methodOverride app req =
    app req'
  where
    req' =
        case join $ lookup "_method" $ queryString req of
            Nothing -> req
            Just m -> req { requestMethod = m }<commit_msg>MethodOverride: only on POST<commit_after>{-# LANGUAGE OverloadedStrings #-}
module Network.Wai.Middleware.MethodOverride
    ( methodOverride
    ) where

import Network.Wai
import Control.Monad (join)

-- | Allows overriding of the HTTP request method via the _method query string
-- parameter.
--
-- This middlware only applies when the initial request method is POST. This
-- allow submitting of normal HTML forms, without worries of semantics
-- mismatches in the HTTP spec.
methodOverride :: Middleware
methodOverride app req =
    app req'
  where
    req' =
        case (requestMethod m, join $ lookup "_method" $ queryString req) of
            ("POST", Just m) -> req { requestMethod = m }
            _ -> req
{'fraction_non_alphanumeric': 0.08353808353808354, 'fraction_numerical': 0.0, 'mean_word_length': 2.9934640522875817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1882821', 'n_tokens_mistral': 336, 'n_tokens_neox': 327, 'n_words': 128}