Magnus Lie Hetland wrote:
> I've named an XMLRPCServlet Main.py; when I refer to it as
> http://www.foo.bar/Main everything works just fine, but when I refer to it as
> simply http://www.foo.bar the client seems to block indefinitely...
> Is this common behaviour, or might it have something to do with my
> setup? (I could of course easily make a rewrite rule in Apache to fix
> this, but that seems unnecessary...)
What happens if you access http://www.foo.bar/ (note the trailing slash)?
WebKit tries to redirect requests for a directory without a trailing slash
to the same URL but including a trailing slash. So it'll try to redirect
http://www.foo.bar to http://www.foo.bar/ . But maybe xmlrpclib doesn't know how to
handle the redirect. I don't know why it would hang, though. I've never
tried to make an XML-RPC servlet be a Main.py before.
> And another thing; when I open an XMLRPCServlet in a browser, it gives
> me an empty web page back. Where does that originate (i.e. how do I
> override it to give some information like "this is not a web page...
> blah, blah, xmlrpc, etc.")?
When I wrote XMLRPCServlet, I never intended it to be accessible both from
XML-RPC and also through a browser. If you look in the source for
XMLRPCServlet, it only responds to POST requests (which is the type of
request made by XML-RPC). If you access it through a browser, you're doing
a GET request, which the servlet just isn't designed to respond to.
If you really want to have it respond to both XML-RPC and browser requests,
you'll have to do some more work in XMLRPCServlet to make that happen.
Doesn't seem worth the trouble to me -- I would just make 2 different
servlets, one for XML-RPC requests and one for browser requests. (Both
servlets could inherit common functionality from a common base class to
avoid code duplication.)
> If you really want to have it respond to both XML-RPC and
> browser requests,
> you'll have to do some more work in XMLRPCServlet to make that happen.
By the way, it might be as simple as adding:
def respondToGet(self, transaction):
transaction.response().write('This servlet only responds to
to your xml-rpc servlet. (untested)