human
I wrote the below code

    class RedirectHandler(urllib_request.HTTPRedirectHandler, ):
        'This    is    an    implementation    of    a    RedirectHandler    to    match    the\n                                functionality    provided    by    httplib2.    It    will    utilize    the    value    of\n                                ``follow_redirects``    that    is    passed    into    ``RedirectHandlerFactory``\n                                to    determine    how    redirects    should    be    handled    in    urllib2.\n                                '
        def redirect_request(self, req, fp, code, msg, hdrs, newurl):
            handler = maybe_add_ssl_handler(newurl, validate_certs)
            if handler:
                urllib_request._opener.add_handler(handler)
            if (follow_redirects == 'urllib2'):
                return urllib_request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, hdrs, newurl)
            elif (follow_redirects in ['no', 'none', False]):
                raise urllib_error.HTTPError(newurl, code, msg, hdrs, fp)
            do_redirect = False
            if (follow_redirects in ['all', 'yes', True]):
                do_redirect = ((code >= 300) and (code < 400))
            elif (follow_redirects == 'safe'):
                m = req.get_method()
                do_redirect = ((code >= 300) and (code < 400) and (m in ('GET', 'HEAD')))
            if do_redirect:
                newurl = newurl.replace('    ', '%20')
                newheaders = dict(((k, v) for (k, v) in req.headers.items() if (k.lower() not in ('content-length', 'content-type'))))
                try:
                    origin_req_host = req.get_origin_req_host()
                except AttributeError:
                    origin_req_host = req.origin_req_host
                return urllib_request.Request(newurl, headers=newheaders, origin_req_host=origin_req_host, unverifiable=True)
            else:
                raise urllib_error.HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    return...

What's a good function header?

=====
What is a Python program to determine    how    redirects    should    be    handled    in    urllib2?
assistant
#Here is Python program to determine    how    redirects    should    be    handled    in    urllib2.

def RedirectHandlerFactory(follow_redirects=None, validate_certs=True):