def send_head(self):
        """Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.
        """

        offerredPath = self.absFilePath
        f = None
        fName = _path.basename(offerredPath)

        urlPath = _U2.unquote(self.path)
        if urlPath == '/':
            self.send_response(307)
            self.send_header("Location", "/" + _U2.quote(fName))
            self.end_headers()
            return None

        ctype = self.guess_type(offerredPath)
        try:
            f = open(offerredPath, 'rb')
        except OSError:
            self.send_error(404, "File not found")
            return None

        try:
            self.send_response(200)
            self.send_header("Content-type", ctype)
            fs = _os.fstat(f.fileno())
            self.send_header("Content-Length", str(fs[6]))
            self.send_header("Content-Disposition", "attachment")
            self.send_header("Last-Modified",
                             self.date_time_string(fs.st_mtime))
            self.end_headers()
            return f
        except:
            f.close()
            raise
def send_head ( self ) : offerredPath = self . absFilePath f = None fName = _path . basename ( offerredPath ) urlPath = _U2 . unquote ( self . path ) if urlPath == '/' : self . send_response ( 307 ) self . send_header ( "Location" , "/" + _U2 . quote ( fName ) ) self . end_headers ( ) return None ctype = self . guess_type ( offerredPath ) try : f = open ( offerredPath , 'rb' ) except OSError : self . send_error ( 404 , "File not found" ) return None try : self . send_response ( 200 ) self . send_header ( "Content-type" , ctype ) fs = _os . fstat ( f . fileno ( ) ) self . send_header ( "Content-Length" , str ( fs [ 6 ] ) ) self . send_header ( "Content-Disposition" , "attachment" ) self . send_header ( "Last-Modified" , self . date_time_string ( fs . st_mtime ) ) self . end_headers ( ) return f except : f . close ( ) raise
Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.