human
Complete the below
def do_check(url):

    ''''This functinality is based on Filippo\'s Valsorda script [1]
    which uses HEAD requests (with fallback in case of 405)
    to follow the redirect path up to the real URL.
    [1] https://gist.github.com/FiloSottile/2077115'
    '''
assistant
#Here is the Python program you requested.
    class HeadRequest(urllib2.Request, ):
        def get_method(self):
            return 'HEAD'
    class HEADRedirectHandler(urllib2.HTTPRedirectHandler, ):
        '\n                        Subclass    the    HTTPRedirectHandler    to    make    it    use    our    \n                        HeadRequest    also    on    the    redirected    URL\n                        '
        def redirect_request(self, req, fp, code, msg, headers, redirected_url):
            if (code in (301, 302, 303, 307)):
                redirected_url = redirected_url.replace('    ', '%20')
                newheaders = dict(((k, v) for (k, v) in req.headers.items() if (k.lower() not in ('content-length', 'content-type'))))
                warn_msg = (((('Got    a    ' + str(code)) + '    redirection    (') + redirected_url) + ').')
                print settings.print_warning_msg(warn_msg)
                return HeadRequest(redirected_url, headers=newheaders, origin_req_host=req.get_origin_req_host(), unverifiable=True)
            else:
                err_msg = str(urllib2.HTTPError(req.get_full_url(), code, msg, headers, fp)).replace(':    ', '    (')
                print settings.print_critical_msg((err_msg + ').'))
                raise SystemExit()
    class HTTPMethodFallback(urllib2.BaseHandler, ):
        '\n                Fallback    to    GET    if    HEAD    is    not    allowed    (405    HTTP    error)\n                '
        def http_error_405(self, req, fp, code, msg, headers):
            fp.read()
            fp.close()
            newheaders = dict(((k, v) for (k, v) in req.headers.items() if (k.lower() not in ('content-length', 'content-type'))))
            return self.parent.open(urllib2.Request(req.get_full_url(), headers=newheaders, origin_req_host=req.get_origin_req_host(), unverifiable=True))
    opener = urllib2.OpenerDirector()
    if menu.options.host:
        opener.addheaders.append(('Host', menu.options.host))
    if menu.options.agent:
        opener.addheaders.append(('User-Agent',...