Adding gzip encoding to Python-based XML-RPC clients is pretty simple. My approach is based upon the observation that (in my code anyway - database queries) the request is usually much smaller than the response. The client's request is never gzip'd. It only tells the server if it will accept a gzip'd response. To add gzip-awareness to xmlrpclib.py take the following steps: 1. Near the top of the file add the following lines: try: import zlib except ImportError: zlib = None 2. In Transport.request, add an Accept-Encoding header if zlib was imported okay: if zlib is not None: h.putheader("Accept-Encoding", "gzip") 3. Replace the "return self.parse_response..." with try: content_encoding = headers["content-encoding"] if content_encoding and content_encoding == "x-gzip": return self.parse_response_gzip(h.getfile()) elif content_encoding: raise ProtocolError(host + handler, 500, "Unknown encoding type: %s" % content_encoding, headers) else: return self.parse_response(h.getfile()) except KeyError: return self.parse_response(h.getfile()) 4. Add a parse_response_gzip method to the Transport class: def parse_response_gzip(self, f): # read response from input file, and parse it #t = time.time() dc = zlib.decompressobj() p, u = getparser() resp = [] append = resp.append read = f.read while 1: response = read(8192) if not response: break append(response) response = dc.decompress(string.join(resp, "")) #print "decompress time: %.2f" % (time.time()-t) #t = time.time() p.feed(response) rest = dc.flush() if rest: p.feed(rest) f.close() p.close() #print "parse time: %.2f" % (time.time()-t) return u.close() To modify an XML-RPC server to handle gzip encoding the steps are similar. 1. Try and import zlib: try: import zlib except ImportError: zlib = None 2. In do_POST, check to see if gzip was sent as an encoding: try: accept_encoding = self.headers["accept-encoding"] if accept_encoding: accept_encoding = map(string.strip, string.split(accept_encoding, ",")) else: accept_encoding = [] except KeyError: accept_encoding = [] 3. Add appropriate tests later in do_POST to make sure you can and should send a gzip'd response. The requirements are that zlib was imported and gzip was one of the encodings sent by the client. I also avoid gzip'ing short responses. if (zlib is not None and "gzip" in accept_encoding and len(response) > 1000): self.send_header("Content-encoding", "x-gzip") response = zlib.compress(response) self.send_header("Content-length", "%d" % len(response))