Mercurial > hg > orthanc
annotate OrthancFramework/Sources/HttpServer/IWebDavBucket.cpp @ 4984:c8cdf5163cd2
cppcheck
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 25 Apr 2022 18:54:45 +0200 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
rev | line source |
---|---|
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * License along with this program. If not, see |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "../PrecompiledHeaders.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "IWebDavBucket.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
27 #include "HttpOutput.h" |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include "../OrthancException.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include "../Toolbox.h" |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 static boost::posix_time::ptime GetNow() |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 return boost::posix_time::second_clock::universal_time(); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 static std::string AddTrailingSlash(const std::string& s) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 if (s.empty() || |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 s[s.size() - 1] != '/') |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 return s + '/'; |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 else |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 return s; |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 namespace Orthanc |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
4252 | 54 IWebDavBucket::Resource::Resource(const std::string& displayName) : |
55 displayName_(displayName), | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 hasModificationTime_(false), |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 creationTime_(GetNow()), |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 modificationTime_(GetNow()) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
4252 | 60 if (displayName.empty() || |
61 displayName.find('/') != std::string::npos || | |
62 displayName.find('\\') != std::string::npos || | |
63 displayName.find('\0') != std::string::npos) | |
64 { | |
65 throw OrthancException(ErrorCode_ParameterOutOfRange, | |
66 "Bad resource name for WebDAV: " + displayName); | |
67 } | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 void IWebDavBucket::Resource::SetCreationTime(const boost::posix_time::ptime& t) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 { |
4246 | 73 if (t.is_special()) |
74 { | |
75 throw OrthancException(ErrorCode_ParameterOutOfRange, "Not a valid date-time"); | |
76 } | |
77 else | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 { |
4246 | 79 creationTime_ = t; |
80 | |
81 if (!hasModificationTime_) | |
82 { | |
83 modificationTime_ = t; | |
84 } | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 void IWebDavBucket::Resource::SetModificationTime(const boost::posix_time::ptime& t) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 { |
4246 | 91 if (t.is_special()) |
92 { | |
93 throw OrthancException(ErrorCode_ParameterOutOfRange, "Not a valid date-time"); | |
94 } | |
95 else | |
96 { | |
97 modificationTime_ = t; | |
98 hasModificationTime_ = true; | |
99 } | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
4246 | 103 static void FormatInternal(pugi::xml_node& node, |
104 const std::string& href, | |
105 const std::string& displayName, | |
106 const boost::posix_time::ptime& creationTime, | |
107 const boost::posix_time::ptime& modificationTime) | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 node.set_name("D:response"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
4246 | 111 node.append_child("D:href").append_child(pugi::node_pcdata).set_value(href.c_str()); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 pugi::xml_node propstat = node.append_child("D:propstat"); |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
114 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
115 static const HttpStatus status = HttpStatus_200_Ok; |
4246 | 116 std::string s = ("HTTP/1.1 " + boost::lexical_cast<std::string>(status) + " " + |
117 std::string(EnumerationToString(status))); | |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
118 propstat.append_child("D:status").append_child(pugi::node_pcdata).set_value(s.c_str()); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 pugi::xml_node prop = propstat.append_child("D:prop"); |
4246 | 121 prop.append_child("D:displayname").append_child(pugi::node_pcdata).set_value(displayName.c_str()); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 |
4247 | 123 // IMPORTANT: Adding the "Z" suffix is mandatory on Windows >= 7 (it indicates UTC) |
124 assert(!creationTime.is_special()); | |
4246 | 125 s = boost::posix_time::to_iso_extended_string(creationTime) + "Z"; |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 prop.append_child("D:creationdate").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
4247 | 128 assert(!modificationTime.is_special()); |
4246 | 129 s = boost::posix_time::to_iso_extended_string(modificationTime) + "Z"; |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 prop.append_child("D:getlastmodified").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 #if 0 |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
133 // Maybe used by davfs2 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
134 prop.append_child("D:quota-available-bytes"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
135 prop.append_child("D:quota-used-bytes"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
136 #endif |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
137 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
138 #if 0 |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 prop.append_child("D:lockdiscovery"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 pugi::xml_node lock = prop.append_child("D:supportedlock"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 pugi::xml_node lockentry = lock.append_child("D:lockentry"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 lockentry.append_child("D:lockscope").append_child("D:exclusive"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 lockentry.append_child("D:locktype").append_child("D:write"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 lockentry = lock.append_child("D:lockentry"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 lockentry.append_child("D:lockscope").append_child("D:shared"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 lockentry.append_child("D:locktype").append_child("D:write"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 #endif |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 |
4246 | 152 |
4252 | 153 IWebDavBucket::File::File(const std::string& displayName) : |
154 Resource(displayName), | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 contentLength_(0), |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 mime_(MimeType_Binary) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
4232
688435755466
added DELETE in WebDAV, first working virtual filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4230
diff
changeset
|
160 |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 void IWebDavBucket::File::Format(pugi::xml_node& node, |
4246 | 162 const std::string& parentPath) const |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 { |
4246 | 164 std::string href; |
4252 | 165 Toolbox::UriEncode(href, AddTrailingSlash(parentPath) + GetDisplayName()); |
166 FormatInternal(node, href, GetDisplayName(), GetCreationTime(), GetModificationTime()); | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 prop.append_child("D:resourcetype"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 std::string s = boost::lexical_cast<std::string>(contentLength_); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 prop.append_child("D:getcontentlength").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 s = EnumerationToString(mime_); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value(s.c_str()); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 void IWebDavBucket::Folder::Format(pugi::xml_node& node, |
4246 | 180 const std::string& parentPath) const |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 { |
4246 | 182 std::string href; |
4252 | 183 Toolbox::UriEncode(href, AddTrailingSlash(parentPath) + GetDisplayName()); |
184 FormatInternal(node, href, GetDisplayName(), GetCreationTime(), GetModificationTime()); | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 prop.append_child("D:resourcetype").append_child("D:collection"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 //prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value("httpd/unix-directory"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 IWebDavBucket::Collection::~Collection() |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 for (std::list<Resource*>::iterator it = resources_.begin(); it != resources_.end(); ++it) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 assert(*it != NULL); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 delete(*it); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 void IWebDavBucket::Collection::AddResource(Resource* resource) // Takes ownership |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 if (resource == NULL) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 throw OrthancException(ErrorCode_NullPointer); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 else |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 resources_.push_back(resource); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 |
4252 | 216 void IWebDavBucket::Collection::ListDisplayNames(std::set<std::string>& target) |
217 { | |
218 for (std::list<Resource*>::iterator it = resources_.begin(); it != resources_.end(); ++it) | |
219 { | |
220 assert(*it != NULL); | |
221 target.insert((*it)->GetDisplayName()); | |
222 } | |
223 } | |
224 | |
225 | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 void IWebDavBucket::Collection::Format(std::string& target, |
4246 | 227 const std::string& parentPath) const |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 pugi::xml_document doc; |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 pugi::xml_node root = doc.append_child("D:multistatus"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 root.append_attribute("xmlns:D").set_value("DAV:"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 |
4246 | 234 { |
235 pugi::xml_node self = root.append_child(); | |
236 | |
4252 | 237 std::vector<std::string> tokens; |
238 Toolbox::SplitUriComponents(tokens, parentPath); | |
239 | |
4246 | 240 std::string folder; |
4252 | 241 if (!tokens.empty()) |
4246 | 242 { |
4252 | 243 folder = tokens.back(); |
4246 | 244 } |
4252 | 245 |
4246 | 246 std::string href; |
4252 | 247 Toolbox::UriEncode(href, Toolbox::FlattenUri(tokens) + "/"); |
4247 | 248 |
249 boost::posix_time::ptime now = GetNow(); | |
250 FormatInternal(self, href, folder, now, now); | |
4246 | 251 |
252 pugi::xml_node prop = self.first_element_by_path("D:propstat/D:prop"); | |
253 prop.append_child("D:resourcetype").append_child("D:collection"); | |
254 } | |
255 | |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 for (std::list<Resource*>::const_iterator |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 it = resources_.begin(); it != resources_.end(); ++it) |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 { |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 assert(*it != NULL); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 pugi::xml_node n = root.append_child(); |
4246 | 261 (*it)->Format(n, parentPath); |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 } |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 decl.append_attribute("version").set_value("1.0"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 decl.append_attribute("encoding").set_value("UTF-8"); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 Toolbox::XmlToString(target, doc); |
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 } |
4228
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
270 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
271 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
272 void IWebDavBucket::AnswerFakedProppatch(HttpOutput& output, |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
273 const std::string& uri) |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
274 { |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
275 /** |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
276 * This is a fake implementation. The goal is to make happy the |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
277 * WebDAV clients that set properties (such as Windows >= 7). |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
278 **/ |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
279 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
280 pugi::xml_document doc; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
281 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
282 pugi::xml_node root = doc.append_child("D:multistatus"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
283 root.append_attribute("xmlns:D").set_value("DAV:"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
284 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
285 pugi::xml_node response = root.append_child("D:response"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
286 response.append_child("D:href").append_child(pugi::node_pcdata).set_value(uri.c_str()); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
287 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
288 response.append_child("D:propstat"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
289 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
290 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
291 decl.append_attribute("version").set_value("1.0"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
292 decl.append_attribute("encoding").set_value("UTF-8"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
293 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
294 std::string s; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
295 Toolbox::XmlToString(s, doc); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
296 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
297 output.AddHeader("Content-Type", "application/xml"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
298 output.SendStatus(HttpStatus_207_MultiStatus, s); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
299 } |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
300 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
301 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
302 void IWebDavBucket::AnswerFakedLock(HttpOutput& output, |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
303 const std::string& uri) |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
304 { |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
305 /** |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
306 * This is a fake implementation. No lock is actually |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
307 * created. The goal is to make happy the WebDAV clients |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
308 * that use locking (such as Windows >= 7). |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
309 **/ |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
310 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
311 pugi::xml_document doc; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
312 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
313 pugi::xml_node root = doc.append_child("D:prop"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
314 root.append_attribute("xmlns:D").set_value("DAV:"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
315 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
316 pugi::xml_node activelock = root.append_child("D:lockdiscovery").append_child("D:activelock"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
317 activelock.append_child("D:locktype").append_child("D:write"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
318 activelock.append_child("D:lockscope").append_child("D:exclusive"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
319 activelock.append_child("D:depth").append_child(pugi::node_pcdata).set_value("0"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
320 activelock.append_child("D:timeout").append_child(pugi::node_pcdata).set_value("Second-3599"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
321 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
322 activelock.append_child("D:lockroot").append_child("D:href") |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
323 .append_child(pugi::node_pcdata).set_value(uri.c_str()); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
324 activelock.append_child("D:owner"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
325 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
326 std::string token = Toolbox::GenerateUuid(); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
327 boost::erase_all(token, "-"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
328 token = "opaquelocktoken:0x" + token; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
329 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
330 activelock.append_child("D:locktoken").append_child("D:href"). |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
331 append_child(pugi::node_pcdata).set_value(token.c_str()); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
332 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
333 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
334 decl.append_attribute("version").set_value("1.0"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
335 decl.append_attribute("encoding").set_value("UTF-8"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
336 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
337 std::string s; |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
338 Toolbox::XmlToString(s, doc); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
339 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
340 output.AddHeader("Lock-Token", token); // Necessary for davfs2 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
341 output.AddHeader("Content-Type", "application/xml"); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
342 output.SendStatus(HttpStatus_201_Created, s); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
343 } |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
344 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
345 |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
346 void IWebDavBucket::AnswerFakedUnlock(HttpOutput& output) |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
347 { |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
348 output.SendStatus(HttpStatus_204_NoContent); |
c8c0bbaaace3
write access to webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4226
diff
changeset
|
349 } |
4226
7bd5eab3ba25
prototyping IWebDavBucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 } |