How to get Hostname using SimpleXMLRPCServer

Roger Binns rogerb at rogerbinns.com
Thu May 6 20:38:59 EDT 2004


Golawala, Moiz M (GE Infrastructure) wrote:
> I figured it out. I realized that in the SimpleXMLRPCRequestHandler there is a doPost method which is inherited from
> BaseHTTPRequestHandler. In the doPost method you can simply ask the self.header for the host variable (clientName =
> self.host["host"]) and you get the client that is invoking the call to the server.

Actually that header is what the client thinks the server is called.  It is
used when you use virtual servers.  Think of an ISP that hosts many sites off
the same machine.  The web server examines the Host header to see which
server's content to serve up.  (In the olden days you would have to make
one server IP address per web site!)

Technically the Host header is part of HTTP/1.1 but most web browsers specify
it (even when speaking HTTP/1.0).  I don't know if XML-RPC clients are
required to specify the Host header, but you will probably find in practise
that most do.

Roger





More information about the Python-list mailing list