[CalendarServer-changes] [7093] CalendarServer/trunk/contrib/performance

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 2 06:57:42 PST 2011


Revision: 7093
          http://trac.macosforge.org/projects/calendarserver/changeset/7093
Author:   exarkun at twistedmatrix.com
Date:     2011-03-02 06:57:42 -0800 (Wed, 02 Mar 2011)
Log Message:
-----------
Add some extra result checking and auth result logging

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/benchlib.py
    CalendarServer/trunk/contrib/performance/httpauth.py

Modified: CalendarServer/trunk/contrib/performance/benchlib.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchlib.py	2011-03-02 14:56:30 UTC (rev 7092)
+++ CalendarServer/trunk/contrib/performance/benchlib.py	2011-03-02 14:57:42 UTC (rev 7093)
@@ -19,10 +19,9 @@
 
 from twisted.internet.defer import (
     FirstError, DeferredList, inlineCallbacks, returnValue)
-# from twisted.internet.task import deferLater
 from twisted.web.http_headers import Headers
-# from twisted.internet import reactor
 from twisted.python.log import msg
+from twisted.web.http import NO_CONTENT, NOT_FOUND
 
 from stats import Duration
 from httpclient import StringProducer, readBody
@@ -45,7 +44,15 @@
 
 
     def deleteResource(self, path):
-        return self.agent.request('DELETE', self._makeURL(path))
+        url = self._makeURL(path)
+        d = self.agent.request('DELETE', url)
+        def deleted(response):
+            if response.code not in (NO_CONTENT, NOT_FOUND):
+                raise Exception(
+                    "Unexpected response to DELETE %s: %d" % (
+                        url, response.code))
+        d.addCallback(deleted)
+        return d
 
 
     def makeCalendar(self, path):

Modified: CalendarServer/trunk/contrib/performance/httpauth.py
===================================================================
--- CalendarServer/trunk/contrib/performance/httpauth.py	2011-03-02 14:56:30 UTC (rev 7092)
+++ CalendarServer/trunk/contrib/performance/httpauth.py	2011-03-02 14:57:42 UTC (rev 7093)
@@ -16,7 +16,9 @@
 
 import urlparse, urllib2
 
+from twisted.python.log import msg
 from twisted.web.http_headers import Headers
+from twisted.web.http import UNAUTHORIZED
 
 # CalDAVClientLibrary
 from protocol.http.authentication.digest import Digest
@@ -107,11 +109,18 @@
 
 
     def _authenticate(self, response, method, uri, headers, bodyProducer):
-        if response.code == 401:
+        if response.code == UNAUTHORIZED:
+            if headers is None:
+                authorization = None
+            else:
+                authorization = headers.getRawHeaders('authorization')
+            msg("UNAUTHORIZED response to %s %s (Authorization=%r)" % (
+                    method, uri, authorization))
             # Look for a challenge
             authorization = response.headers.getRawHeaders('www-authenticate')
             if authorization is None:
-                raise Exception("401 response with no WWW-Authenticate header")
+                raise Exception(
+                    "UNAUTHORIZED response with no WWW-Authenticate header")
 
             for auth in authorization:
                 challenge = self._parse(auth)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110302/3440cee0/attachment.html>


More information about the calendarserver-changes mailing list