def fix_request_method_tween_factory(handler, registry):
    """ Fix Request method changed by mod_wsgi.
    See: https://github.com/GrahamDumpleton/mod_wsgi/issues/2
    Apache config:
        SetEnvIf Request_Method HEAD X_REQUEST_METHOD=HEAD
    """

    def fix_request_method_tween(request):
        environ = request.environ
        if 'X_REQUEST_METHOD' in environ:
            environ['REQUEST_METHOD'] = environ['X_REQUEST_METHOD']
        return handler(request)

    return fix_request_method_tween