[BangPypers] Need help with the 'transport' for setting the header while calling a function at server side

Usman Ajmal uzmanajmal at gmail.com
Fri Sep 12 20:39:00 CEST 2008

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))

#-----------------------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" %
       def send_request(self, connection, handler, request_body):
           connection.putrequest("POST", handler)
           connection.putheader("Authorization","Basic %s" %

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()

    #Generating a random string

    #For calculating the hash of some arbitrary message
    hashValue = sha.new()
    hashValue.update("(.2).ch^kjdw*()!hjsu7 at hsue

    #Updating the hash with the previously generated random string
    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()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20080912/469a2dd6/attachment.htm>

More information about the BangPypers mailing list