dav/methods.c

changeset 13
8a0cc4d90de7
parent 5
88625853ae74
child 15
182af08b4813
equal deleted inserted replaced
12:493128ef1b12 13:8a0cc4d90de7
156 DavResource *root = resource_new_href(sn, util_url_path(url)); 156 DavResource *root = resource_new_href(sn, util_url_path(url));
157 157
158 xmlDoc *doc = xmlReadMemory(response->space, response->size, url, NULL, 0); 158 xmlDoc *doc = xmlReadMemory(response->space, response->size, url, NULL, 0);
159 if(!doc) { 159 if(!doc) {
160 // TODO: free stuff 160 // TODO: free stuff
161 sn->error = DAV_ERROR;
161 return NULL; 162 return NULL;
162 } 163 }
163 164
164 xmlNode *xml_root = xmlDocGetRootElement(doc); 165 xmlNode *xml_root = xmlDocGetRootElement(doc);
165 xmlNode *node = xml_root->children; 166 xmlNode *node = xml_root->children;
183 if(node->type == XML_ELEMENT_NODE) { 184 if(node->type == XML_ELEMENT_NODE) {
184 if(xstreq(node->name, "href")) { 185 if(xstreq(node->name, "href")) {
185 xmlNode *href_content = node->children; 186 xmlNode *href_content = node->children;
186 if(href_content->type != XML_TEXT_NODE) { 187 if(href_content->type != XML_TEXT_NODE) {
187 // error 188 // error
189 resource->session->error = DAV_ERROR;
188 return 1; 190 return 1;
189 } 191 }
190 if(xstreq(resource->href, href_content->content)) { 192 if(xstreq(resource->href, href_content->content)) {
191 res = resource; 193 res = resource;
192 } else { 194 } else {
203 if(xstreq(n->name, "prop")) { 205 if(xstreq(n->name, "prop")) {
204 prop_node = n; 206 prop_node = n;
205 } else if(xstreq(n->name, "status")) { 207 } else if(xstreq(n->name, "status")) {
206 xmlNode *status_node = n->children; 208 xmlNode *status_node = n->children;
207 if(status_node->type != XML_TEXT_NODE) { 209 if(status_node->type != XML_TEXT_NODE) {
210 resource->session->error = DAV_ERROR;
208 return 1; 211 return 1;
209 } 212 }
210 sstr_t status_str = sstr((char*)status_node->content); 213 sstr_t status_str = sstr((char*)status_node->content);
211 if(status_str.length < 13) { 214 if(status_str.length < 13) {
215 resource->session->error = DAV_ERROR;
212 return 1; 216 return 1;
213 } 217 }
214 status_str = sstrsubsl(status_str, 9, 3); 218 status_str = sstrsubsl(status_str, 9, 3);
215 if(!sstrcmp(status_str, S("200"))) { 219 if(!sstrcmp(status_str, S("200"))) {
216 ok = 1; 220 ok = 1;

mercurial