<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _patch_redirect(session):
 # type: (requests.Session) -> None """Whether redirect policy should be applied based on status code. HTTP spec says that on 301/302 not HEAD/GET, should NOT redirect. But requests does, to follow browser more than spec https://github.com/requests/requests/blob/f6e13ccfc4b50dc458ee374e5dba347205b9a2da/requests/sessions.py#L305-L314 This patches "requests" to be more HTTP compliant. Note that this is super dangerous, since technically this is not public API. """

    def enforce_http_spec(resp, request):
        if resp.status_code in (301, 302) and \
                request.method not in ['GET', 'HEAD']:
            return False
        return True

    redirect_logic = session.resolve_redirects

    def wrapped_redirect(resp, req, **kwargs):
        attempt = enforce_http_spec(resp, req)
        return redirect_logic(resp, req, **kwargs) if attempt else []
    wrapped_redirect.is_msrest_patched = True  # type: ignore

    session.resolve_redirects = wrapped_redirect