225 |
225 |
226 struct stat st; |
226 struct stat st; |
227 if(stat(ppath, &st) != 0) { |
227 if(stat(ppath, &st) != 0) { |
228 perror("webdav_propfind: stat"); |
228 perror("webdav_propfind: stat"); |
229 fprintf(stderr, " file: %s\n", ppath); |
229 fprintf(stderr, " file: %s\n", ppath); |
|
230 |
|
231 /* TODO: check errno only set status */ |
|
232 protocol_status(sn, rq, 404, NULL); |
|
233 pblock_removekey(pb_key_content_type, rq->srvhdrs); |
|
234 pblock_nninsert("content-length", 0, rq->srvhdrs); |
|
235 http_start_response(sn, rq); |
|
236 |
230 return REQ_ABORTED; |
237 return REQ_ABORTED; |
231 } |
238 } |
232 |
239 |
233 /* |
240 /* |
234 * if the requested webdav resource(file) is a directory, we create |
241 * if the requested webdav resource(file) is a directory, we create |
665 |
672 |
666 sbuf_puts(out, "\n</D:prop>\n<D:status>HTTP/1.1 200 OK</D:status>\n"); |
673 sbuf_puts(out, "\n</D:prop>\n<D:status>HTTP/1.1 200 OK</D:status>\n"); |
667 sbuf_puts(out, "</D:propstat>\n"); |
674 sbuf_puts(out, "</D:propstat>\n"); |
668 } |
675 } |
669 |
676 |
670 for(int i=0;i<propstat->map->size;i++) { |
677 UcxMapIterator iter = ucx_map_iterator(propstat->map); |
671 UcxMapElement *elm = &propstat->map->map[i]; |
678 UCX_MAP_FOREACH(UcxDlist*, proplist, propstat->map, iter) { |
672 while(elm) { |
679 if(proplist) { |
673 UcxDlist *proplist = (UcxDlist*)elm->data; |
680 sbuf_puts(out, "<D:propstat>\n<D:prop>\n"); |
674 |
681 |
675 if(proplist) { |
682 DAV_FOREACH(prop, proplist) { |
676 sbuf_puts(out, "<D:propstat>\n<D:prop>\n"); |
683 xmlelm_write((XmlElement*)prop->data, out, wv); |
|
684 } |
677 |
685 |
678 DAV_FOREACH(prop, proplist) { |
686 sbuf_puts(out, "\n</D:prop>\n<D:status>"); |
679 xmlelm_write((XmlElement*)prop->data, out, wv); |
|
680 } |
|
681 |
687 |
682 sbuf_puts(out, "\n</D:prop>\n<D:status>"); |
688 int status = *(int*)iter.cur->key.data; |
683 |
689 if(status < 1000 && status > 0) { |
684 int status = *(int*)elm->key.data; |
690 char buf[5]; |
685 if(status < 1000 && status > 0) { |
691 buf[4] = 0; |
686 char buf[5]; |
692 sprintf(buf, "%d ", status); |
687 buf[4] = 0; |
693 sbuf_puts(out, "HTTP/1.1 "); |
688 sprintf(buf, "%d ", status); |
694 sbuf_puts(out, buf); |
689 sbuf_puts(out, "HTTP/1.1 "); |
695 sbuf_puts(out, (char*)protocol_status_message(status)); |
690 sbuf_puts(out, buf); |
|
691 sbuf_puts(out, (char*)protocol_status_message(status)); |
|
692 } |
|
693 |
|
694 sbuf_puts(out, "</D:status>\n</D:propstat>\n"); |
|
695 } |
696 } |
696 |
697 |
697 elm = elm->next; |
698 sbuf_puts(out, "</D:status>\n</D:propstat>\n"); |
698 } |
699 } |
699 } |
700 } |
700 } |
701 } |