I am getting an Internal Server Error 500 when i run my client code. I am trying to call a function at the server side which for now only returns a string. Meanwhile this calling i also set the header of HTTP request. Following are my client and server code. Am i doing something wrong?
#-----------------------Server code----------------------------- import SimpleXMLRPCServer class AuthenticationFunctions: def system_auth(self): # No need to print here if you are going to print it at the client side. Return it instead. return "something..." server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000)) server.register_instance(AuthenticationFunctions()) server.serve_forever() #-----------------------Client code----------------------------- import sha,random, os, time, sha, quopri, xmlrpclib class SecureTransport(xmlrpclib.Transport): def set_authorization(self, ustring, text_ucert): self.authorization = quopri.encodestring("%s:%s" % (ustring,text_ucert)) def send_request(self, connection, handler, request_body): connection.putrequest("POST", handler) connection.putheader("Authorization","Basic %s" % self.authorization) def caller(): #Opening file named newcert.pem in which certificate generated via openssl command is placed infile = open('newcert.pem', "r+") if infile: text_ucert = infile.read() infile.close() #Generating a random string random.seed(); ustring_raw="%s_%f_%f"%(os.getpid(),time.time(),random.random()) #For calculating the hash of some arbitrary message hashValue = sha.new() hashValue.update("(.2).ch^kjdw*()[EMAIL PROTECTED] @!jssljdu2837.kd'[EMAIL PROTECTED]&") #Updating the hash with the previously generated random string hashValue.update(ustring_raw) ustring = quopri.encodestring(hashValue.digest()) #Instantiating the transport t = SecureTransport() t.set_authorization(ustring, text_ucert) server = xmlrpclib.Server('http://localhost:8000',transport=t) #Calling some arbitrary function at server side print server.system_auth() caller()
-- http://mail.python.org/mailman/listinfo/python-list