Changeset 24679

Show
Ignore:
Timestamp:
09/05/2008 05:18:26 AM (10 months ago)
Author:
therve
Message:
Merge xmlrpc-empty-response-3399 Author: therve Reviewer: exarkun Fixes #3399 Fix xmlrpc client so that he manages to return an error for buggy servers sending an empty response.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/twisted/web/test/test_xmlrpc.py

    r23210 r24679  
    451451        self.queryFactory.badStatus('status', 'message') 
    452452        return d 
     453 
     454    def test_parseResponseWithoutData(self): 
     455        """ 
     456        Some server can send a response without any data: 
     457        L{_QueryFactory.parseResponse} should catch the error and call the 
     458        result errback. 
     459        """ 
     460        content = """ 
     461<methodResponse> 
     462 <params> 
     463  <param> 
     464  </param> 
     465 </params> 
     466</methodResponse>""" 
     467        d = self.queryFactory.deferred 
     468        self.queryFactory.parseResponse(content) 
     469        return self.assertFailure(d, IndexError) 
  • trunk/twisted/web/xmlrpc.py

    r24441 r24679  
    305305            return 
    306306        try: 
    307             response = xmlrpclib.loads(contents) 
     307            response = xmlrpclib.loads(contents)[0][0] 
    308308        except: 
    309309            deferred, self.deferred = self.deferred, None 
     
    311311        else: 
    312312            deferred, self.deferred = self.deferred, None 
    313             deferred.callback(response[0][0]) 
     313            deferred.callback(response) 
    314314 
    315315    def clientConnectionLost(self, _, reason): 
     
    392392 
    393393    def callRemote(self, method, *args): 
     394        """ 
     395        Call remote XML-RPC C{method} with given arguments. 
     396 
     397        @return: a L{defer.Deferred} that will fire with the method response, 
     398            or a failure if the method failed. Generally, the failure type will 
     399            be L{Fault}, but you can also have an C{IndexError} on some buggy 
     400            servers giving empty responses. 
     401        """ 
    394402        factory = self.queryFactory( 
    395403            self.path, self.host, method, self.user,