def __evaluateResponse(self, method, response):
     """ Evaluates the response of the WebDAV server. """
     
     status, reason = response.status, response.reason
     self.logger.debug("Method: " + method + " Status %d: " % status + reason)
     
     if status >= Constants.CODE_LOWEST_ERROR:     # error has occured ?
         self.logger.debug("ERROR Response: " + response.read().strip())
         
         # identify authentication CODE_UNAUTHORIZED, throw appropriate exception
         if status == Constants.CODE_UNAUTHORIZED:
             raise AuthorizationError(reason, status, response.msg["www-authenticate"])
         
         response.close()
         raise WebdavError(reason, status)
     
     if status == Constants.CODE_MULTISTATUS:
         content = response.read()
         ## check for UTF-8 encoding
         try:
             response.root = Parser().parse(content)
         except ExpatError, error:
             errorMessage = "Invalid XML document has been returned.\nReason: '%s'" % str(error.args)
             raise WebdavError(errorMessage)
         try:
             response.msr = MultiStatusResponse(response.root)
         except ResponseFormatError:
             raise WebdavError("Invalid WebDAV response.")
         response.close()
         self.logger.debug("RESPONSE (Multi-Status): " + unicode(response.msr).strip())
Example #2
0
 def __evaluateResponse(self, method, response):
     """ Evaluates the response of the WebDAV server. """
     
     status, reason = response.status, response.reason
     self.logger.debug("Method: " + method + " Status %d: " % status + reason)
     
     if status >= Constants.CODE_LOWEST_ERROR:     # error has occured ?
         self.logger.debug("ERROR Response: " + response.read())
         response.close()
         raise WebdavError(reason, status)
     
     if status == Constants.CODE_MULTISTATUS:
         content = response.read()
         ## check for UTF-8 encodig
         response.root = Parser().parse(content)
         try:
             response.msr = MultiStatusResponse(response.root)
         except ResponseFormatError:
             raise WebdavError("Invalid WebDAV response.")
         response.close()
         self.logger.debug("RESPONSE (Multi-Status): " + unicode(response.msr))
     elif method == 'LOCK' and status == Constants.CODE_SUCCEEDED:
         response.parse_lock_response()
         response.close()
     elif method != 'GET' and method != 'PUT':
         self.logger.debug("RESPONSE Body: " + response.read())
         response.close()
     return response