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