1

我正在尝试为我的应用程序开发一个简单的 CalDAV 服务器,在这方面,我正在尝试为日历客户端的初始 PROPFIND 请求提供服务。

日历客户端请求服务器设置一组属性(如下所示)以响应请求:

方法:PROPFIND /calendars/user/ HTTP/1.1

请求标头

Accept-encoding  gzip, deflate
Accept  */*
Connection  keep-alive
Prefer  return=minimal
Host  192.168.0.12:8080
Brief  t
User-agent  Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1
Depth  0
Authorization  Basic YWRtaW46cGFzc3dvcmQ=
Accept-language  en-us
Content-type  text/xml
Content-length  743

请求正文

<?xml version="1.0" encoding="UTF-8"?>
<A:propfind xmlns:A="DAV:">
 <A:prop>
   <B:calendar-home-set xmlns:B="urn:ietf:params:xml:ns:caldav"/>
   <B:calendar-user-address-set xmlns:B="urn:ietf:params:xml:ns:caldav"/>
   <A:current-user-principal/>
   <A:displayname/>
   <C:dropbox-home-URL xmlns:C="http://calendarserver.org/ns/"/>
   <C:email-address-set xmlns:C="http://calendarserver.org/ns/"/>
   <C:notification-URL xmlns:C="http://calendarserver.org/ns/"/>
   <A:principal-collection-set/>
   <A:principal-URL/>
   <A:resource-id/>
   <B:schedule-inbox-URL xmlns:B="urn:ietf:params:xml:ns:caldav"/>
   <B:schedule-outbox-URL xmlns:B="urn:ietf:params:xml:ns:caldav"/>
   <A:supported-report-set/>
 </A:prop>
</A:propfind>

作为对上述PROPFIND请求的响应,我将响应设置为如下所示:

响应头

Accept-encoding  gzip, deflate
Accept  */*
Connection  keep-alive
Prefer  return=minimal
Host  192.168.0.12:8080
Brief  t
User-agent  Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1
Depth  0
Authorization  Basic YWRtaW46cGFzc3dvcmQ=
Accept-language  en-us
Content-type  text/xml
Content-length  743

响应体

String response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"+
            "<A:multistatus xmlns:A=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\">" +
            "<A:response>" +
                "<A:href>/calendars/user/</A:href>" + 
                "<A:propstat>" +
                    "<A:prop>" +
                        "<B:calendar-home-set xmlns:B=\"urn:ietf:params:xml:ns:caldav\"><B:href>/admin/calendar/test/</B:href></B:calendar-home-set>"+
                        "<B:calendar-user-address-set xmlns:B=\"urn:ietf:params:xml:ns:caldav\"/><A:href>mailto:admin@example.de</A:href></B:calendar-user-address-set>"+
                        "<A:current-user-principal><A:href>/principals/users/admin</A:href></A:current-user-principal>"+
                        "<A:displayname>Test calendar</A:displayname>"+
                        "<A:principal-collection-set><A:href>/principals/users/</A:href><A:href>/principals/groups/</A:href></A:principal-collection-set>"+
                        "<A:principal-URL><A:href>http://192.168.0.12/principals/users/admin/</A:href></A:principal-URL>"+
                        "<A:supported-report-set xmlns:n2=\"urn:inverse:params:xml:ns:inverse-dav\" xmlns:n3=\"urn:ietf:params:xml:ns:carddav\" xmlns:A=\"DAV:\" xmlns:n1=\"urn:ietf:params:xml:ns:caldav\">"+ 
                        "<A:supported-report><A:report><n1:calendar-query/></A:report></A:supported-report>"+
                        "<A:supported-report><A:report><n1:calendar-multiget/></A:report></A:supported-report>"+
                        "<A:supported-report><A:report><n2:acl-query/></A:report></A:supported-report>"+
                        "<A:supported-report><A:report><A:sync-collection/></A:report></A:supported-report>"+
                        "<A:supported-report><A:report><A:expand-property/></A:report></A:supported-report>"+
                        "<A:supported-report><A:report><n3:addressbook-query/></A:report></A:supported-report>"+
                        "<A:supported-report><A:report><n1:free-busy-query/></A:report></A:supported-report>"+
                        "</A:supported-report-set>"+    
                        "<B:schedule-inbox-URL xmlns='urn:ietf:params:xml:ns:caldav'><href xmlns='DAV:'>/calendars/__uids__/admin/inbox/</href></B:schedule-inbox-URL>"+
                        "<B:schedule-outbox-URL xmlns='urn:ietf:params:xml:ns:caldav'><href xmlns='DAV:'>/calendars/__uids__/admin/outbox/</href></B:schedule-outbox-URL>"+
                        "<C:dropbox-home-URL xmlns='http://calendarserver.org/ns/'><href xmlns='DAV:'>/calendars/__uids__/admin/dropbox/</href></C:ropbox-home-URL>"+
                    "</A:prop>" +
                    "<A:status>HTTP/1.1 200 OK</A:status>" +
                "</A:propstat>" +
            "</A:response>" +
        "</A:multistatus>";

向客户端发送响应后,客户端再次发回相同的属性(不是全部 - 如下所示)。

<?xml version="1.0" encoding="UTF-8"?>
<A:propfind xmlns:A="DAV:">
  <A:prop>
    <A:current-user-principal/>
    <A:principal-collection-set/>
  </A:prop>
</A:propfind>

那么谁能让我知道我在设置这些属性时哪里出错了?

4

1 回答 1

1

正如 Evert 在评论部分提到的,客户有点健谈。经过几次观察,我什至发现了相同的结果。

于 2016-04-13T14:46:14.283 回答