我正在尝试为我的应用程序开发一个简单的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>
所以任何人都可以让我知道在设置这些属性时我在哪里出错了?
答案 0 :(得分:1)
正如Evert在评论部分提到的,客户端有点健谈。经过几次观察,我发现了同样的情况。