[CalendarServer-changes] [14790] CalDAVClientLibrary/trunk/caldavclientlibrary

source_changes at macosforge.org source_changes at macosforge.org
Sun May 17 23:27:37 PDT 2015


Revision: 14790
          http://trac.calendarserver.org//changeset/14790
Author:   cdaboo at apple.com
Date:     2015-05-17 23:27:37 -0700 (Sun, 17 May 2015)
Log Message:
-----------
Add support for OPTIONS request.

Modified Paths:
--------------
    CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py
    CalDAVClientLibrary/trunk/caldavclientlibrary/client/clientsession.py

Added Paths:
-----------
    CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/options.py

Modified: CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py
===================================================================
--- CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py	2015-05-15 00:42:06 UTC (rev 14789)
+++ CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/__init__.py	2015-05-18 06:27:37 UTC (rev 14790)
@@ -33,6 +33,7 @@
     "mkdir",
     "mv",
     "notifications",
+    "options",
     "post",
     "principal",
     "props",

Added: CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/options.py
===================================================================
--- CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/options.py	                        (rev 0)
+++ CalDAVClientLibrary/trunk/caldavclientlibrary/browser/commands/options.py	2015-05-18 06:27:37 UTC (rev 14790)
@@ -0,0 +1,72 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from caldavclientlibrary.browser.command import Command
+from caldavclientlibrary.browser.command import WrongOptions
+from caldavclientlibrary.protocol.url import URL
+import os
+import getopt
+import shlex
+
+class Cmd(Command):
+
+    def __init__(self):
+        super(Command, self).__init__()
+        self.cmds = ("options",)
+        self.do_wd_complete = True
+
+
+    def execute(self, cmdname, options):
+
+        opts, args = getopt.getopt(shlex.split(options), '')
+
+        data = None
+        content_type = None
+        path = None
+
+        for name, _ignore_value in opts:
+
+            print "Unknown option: %s" % (name,)
+            print self.usage(cmdname)
+            raise WrongOptions
+
+        if len(args) > 1:
+            print "Wrong number of arguments: %d" % (len(args),)
+            print self.usage(cmdname)
+            raise WrongOptions
+        elif args:
+            path = args[0]
+            if not path.startswith("/"):
+                path = os.path.join(self.shell.wd, path)
+        else:
+            path = self.shell.wd
+
+        resource = URL(url=path)
+        self.shell.account.session.writeData(resource, data, content_type, method="OPTIONS")
+
+        return True
+
+
+    def usage(self, name):
+        return """Usage: %s OPTIONS PATH
+PATH is a relative or absolute path.
+
+Options: None
+""" % (name,)
+
+
+    def helpDescription(self):
+        return "Execute an OPTIONS request on the server."

Modified: CalDAVClientLibrary/trunk/caldavclientlibrary/client/clientsession.py
===================================================================
--- CalDAVClientLibrary/trunk/caldavclientlibrary/client/clientsession.py	2015-05-15 00:42:06 UTC (rev 14789)
+++ CalDAVClientLibrary/trunk/caldavclientlibrary/client/clientsession.py	2015-05-18 06:27:37 UTC (rev 14790)
@@ -41,6 +41,7 @@
 from caldavclientlibrary.protocol.webdav.get import Get
 from caldavclientlibrary.protocol.webdav.makecollection import MakeCollection
 from caldavclientlibrary.protocol.webdav.move import Move
+from caldavclientlibrary.protocol.webdav.options import Options
 from caldavclientlibrary.protocol.webdav.post import Post
 from caldavclientlibrary.protocol.webdav.principalmatch import PrincipalMatch
 from caldavclientlibrary.protocol.webdav.propall import PropAll
@@ -727,6 +728,8 @@
             request = Put(self, rurl.relativeURL())
         elif method == "POST":
             request = Post(self, rurl.relativeURL())
+        elif method == "OPTIONS":
+            request = Options(self, rurl.relativeURL())
 
         dout = ResponseDataString()
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150517/8cfcf690/attachment.html>


More information about the calendarserver-changes mailing list