Need XML-RPC help

Ng Pheng Siong ngps at madcap.dyn.ml.org
Mon Jan 24 10:12:58 EST 2000


According to Tony McDonald  <tony.mcdonald at ncl.ac.uk>:
>I can't get XML-RPC to work through our proxy.

Try this patch:

*** xmlrpclib.py.orig	Sun Sep 19 16:00:47 1999
--- xmlrpclib.py	Sun Sep 19 16:01:02 1999
***************
*** 553,564 ****
      # client identifier (may be overridden)
      user_agent = "xmlrpclib.py/%s (by www.pythonware.com)" % __version__
  
      def request(self, host, handler, request_body):
          # issue XML-RPC request
  
          import httplib
!         h = httplib.HTTP(host)
!         h.putrequest("POST", handler)
  
          # required by HTTP/1.1
          h.putheader("Host", host)
--- 553,576 ----
      # client identifier (may be overridden)
      user_agent = "xmlrpclib.py/%s (by www.pythonware.com)" % __version__
  
+     def __init__(self, proxy_host=None, proxy_port=8080):
+         self.use_proxy=0
+         if proxy_host is not None:
+             self.proxy_host=proxy_host
+             self.proxy_port=proxy_port
+             self.use_proxy=1
+ 
      def request(self, host, handler, request_body):
          # issue XML-RPC request
  
          import httplib
!         req='http://%s%s' % (host, handler)
! 
!         if self.use_proxy:
!             h = httplib.HTTP(self.proxy_host, self.proxy_port)
!         else:
!             h = httplib.HTTP(host)
!         h.putrequest("POST", req)
  
          # required by HTTP/1.1
          h.putheader("Host", host)

-- 
Ng Pheng Siong <ngps at post1.com>


-- 
Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps




More information about the Python-list mailing list