⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htdav.c

📁 www工具包. 这是W3C官方支持的www支撑库. 其中提供通用目的的客户端的WebAPI: complete HTTP/1.1 (with caching, pipelining, PUT, POS
💻 C
📖 第 1 页 / 共 3 页
字号:
} PUBLIC BOOL HTPROPPATCHAnchor (HTRequest * request,                               HTAnchor * dst,                               const char * xmlbody,                               HTDAVHeaders * headers) {    if (request && dst && xmlbody) {       HTParentAnchor * body = HTTmpAnchor(NULL);       HTAnchor_setDocument (body, (void *)xmlbody);       HTAnchor_setFormat (body, HTAtom_for ("text/xml"));       HTAnchor_setLength (body, strlen(xmlbody));                      return HTPROPPATCHDocumentAnchor (request,dst,body,headers);    }    return NO;}/*** This PROPPATCH request set or removes properties from the resource ** indicated by the absolute URI (parameter uri). */PUBLIC BOOL HTPROPPATCHAbsolute (HTRequest * request,                                const char * uri,                                const char * xmlbody,                                HTDAVHeaders * headers) {    if (request && uri && *uri && xmlbody && *xmlbody) {        HTAnchor *dst = HTAnchor_findAddress (uri);        return HTPROPPATCHAnchor (request,dst,xmlbody,headers);    }    return NO;}/*** This PROPPATCH request sets/removes the properties from the resource ** indicated by a relative URI, which is made absolute by using ** the base anchor.*/PUBLIC BOOL HTPROPPATCHRelative (HTRequest * request,                                 const char * relative,                                HTParentAnchor * base,                                const char * xmlbody,                                HTDAVHeaders * headers) {    BOOL status = NO;    if (request && relative && base && xmlbody && *xmlbody) {         char * base_uri = HTAnchor_address ((HTAnchor *)base);         char * full_uri = HTParse (relative,base_uri,PARSE_ACCESS|PARSE_HOST| \                                                 PARSE_PATH|PARSE_PUNCTUATION);         status = HTPROPPATCHAbsolute (request,full_uri,xmlbody,headers);         HT_FREE (full_uri);         HT_FREE (base_uri);    }    return status;}/* --------------------------------------------------------------------------*//*                             MKCOL REQUESTS                                *//* --------------------------------------------------------------------------*//*** MKCOL Requests** MKCOL requests creates a collection. The resource indicated by HTAnchor *** dst parameter must not be a "non-null" resource, but all it ancestors** must exist.** Headers:**      If header may be used.*/PUBLIC BOOL HTMKCOLAnchor (HTRequest * request,                            HTAnchor * dst,                           HTDAVHeaders * headers) {    if (request && dst) {        /* set method and request-URI */        HTRequest_setMethod (request,METHOD_MKCOL);        HTRequest_setAnchor (request,dst);        HTTRACE (PROT_TRACE,"HTDAV.... Method set to MKCOL\n");                /* set headers */        HTTRACE (PROT_TRACE,"HTDAV.... Seting default Headers \n");        HTRequest_addCacheControl (request,"no-cache","");        HTRequest_addGnHd (request,HT_G_PRAGMA_NO_CACHE);                if (headers) { /* WebDAV specific headers */            HTTRACE (PROT_TRACE,"HTDAV.... Setting WebDAV headers \n");            if (headers->If) /* only IF header may be used */                HTRequest_addExtraHeader (request,"If",headers->If);        }        return HTLoad (request,NO);    }    return NO;}/*** This MKCOL request tries to create the resource ** indicated by the absolute URI (parameter uri). */PUBLIC BOOL HTMKCOLAbsolute (HTRequest * request,                             const char * uri,                             HTDAVHeaders * headers) {    if (request && uri && *uri) {        HTAnchor *dst = HTAnchor_findAddress (uri);        return HTMKCOLAnchor (request,dst,headers);    }    return NO;}/*** This MKCOL request tries to create the resource indicated** by a relative URI, which is made absolute by using the** base anchor.*/PUBLIC BOOL HTMKCOLRelative (HTRequest * request,                              const char * relative,                             HTParentAnchor * base,                             HTDAVHeaders * headers) {    BOOL status = NO;    if (request && relative && base) {         char * base_uri = HTAnchor_address ((HTAnchor *)base);         char * full_uri = HTParse (relative,base_uri,PARSE_ACCESS|PARSE_HOST| \                                                 PARSE_PATH|PARSE_PUNCTUATION);         status = HTMKCOLAbsolute (request,full_uri,headers);         HT_FREE (full_uri);         HT_FREE (base_uri);    }    return status;}/* --------------------------------------------------------------------------*//*                              COPY REQUESTS                                *//* --------------------------------------------------------------------------*//*** COPY Requests** COPY requests copies the Request-URI resource (indicated by the parameter** HTAnchor *src) to the resource indicated by the Destination header (it must** be set in HTDAVHeaders object - so, this object must NOT be NULL).** A xml message body may also be set, with the propertybehavior xml element,** which indicates what should be the server behavior when copying the resouce** properties.** Headers:**      Destination header is mandatory!**      If header may be used.**      Depth header may be "0" or "infinity"**      Overwrite header may be used*/PUBLIC BOOL HTCOPYDocumentAnchor (HTRequest * request,                                  HTAnchor * src,                                  HTParentAnchor * xmlbody,                                  HTDAVHeaders * headers) {            if (request && src && headers) {        /* set method and request-URI */        HTRequest_setMethod (request,METHOD_COPY);        HTRequest_setAnchor (request,src);        HTTRACE (PROT_TRACE,"HTDAV.... Method set to COPY\n");        /* set headers */        HTTRACE (PROT_TRACE,"HTDAV.... Seting default Headers \n");        HTRequest_addCacheControl (request,"no-cache","");        HTRequest_addGnHd (request,HT_G_PRAGMA_NO_CACHE);         /* WebDAV specific headers - Destination is mandatory! */        if (headers->Destination && *headers->Destination) {             HTTRACE (PROT_TRACE,"HTDAV.... Setting WebDAV headers \n");            HTRequest_addExtraHeader (request,"Destination",headers->Destination);            if (headers->If) /* If header may be used */                HTRequest_addExtraHeader (request,"If",headers->If);            if (headers->Overwrite != ' ') {                char over[] = { headers->Overwrite, '\0' };                HTRequest_addExtraHeader (request,"Overwirte", over );             }            if (headers->Depth) {                if (!strcasecomp (headers->Depth,"0") ||                     !strcasecomp (headers->Depth,"infinity"))                       HTRequest_addExtraHeader (request,"Depth",headers->Depth);            }        }         else return NO;        /* set body - if there is a body */        if (xmlbody) {            HTTRACE (PROT_TRACE,"HTDAV.... Setting Entity Body \n");            HTRequest_setEntityAnchor (request,xmlbody);             HTRequest_setPostCallback (request, HTEntity_callback);        }        return HTLoad (request,NO);    }    return NO;}PUBLIC BOOL HTCOPYAnchor (HTRequest * request,                            HTAnchor * src,                           const char * xmlbody,                           HTDAVHeaders * headers) {         if (request && src && headers) {        HTParentAnchor * body = NULL;        if (xmlbody) {            body = HTTmpAnchor(NULL);            HTAnchor_setDocument (body, (void *)xmlbody);            HTAnchor_setFormat (body, HTAtom_for ("text/xml"));            HTAnchor_setLength (body, strlen(xmlbody));        }        return HTCOPYDocumentAnchor (request,src,body,headers);      }    return NO;}/*** This COPY request copies the resource indicated by an absolute URI** (parameter uri) to the URI in Destination header. */PUBLIC BOOL HTCOPYAbsolute (HTRequest * request,                            const char * uri,                            const char * xmlbody,                            HTDAVHeaders * headers) {    if (request && uri && *uri && headers) {        HTAnchor *src = HTAnchor_findAddress (uri);        return HTCOPYAnchor (request,src,xmlbody,headers);    }    return NO;}/*** This COPY request copies the resource indicated by a relative URI,** which is made absolute by using the base anchor. */PUBLIC BOOL HTCOPYRelative (HTRequest * request,                                 const char * relative,                                HTParentAnchor * base,                                const char * xmlbody,                                HTDAVHeaders * headers) {    BOOL status = NO;    if (request && relative && base && headers) {         char * base_uri = HTAnchor_address ((HTAnchor *)base);         char * full_uri = HTParse (relative,base_uri,PARSE_ACCESS|PARSE_HOST| \                                                 PARSE_PATH|PARSE_PUNCTUATION);         status = HTCOPYAbsolute (request,full_uri,xmlbody,headers);         HT_FREE (full_uri);         HT_FREE (base_uri);    }    return status;}/* --------------------------------------------------------------------------*//*                              MOVE REQUESTS                                *//* --------------------------------------------------------------------------*//*** MOVE Requests** MOVE requests moves the Request-URI resource (indicated by the parameter** HTAnchor *src) to the resource indicated by the Destination header (it must** be set in HTDAVHeaders object - so, this object must NOT be NULL).** A xml message body may also be set, with the propertybehavior xml element,** which indicates what should be the server behavior when copying the resouce** properties.** Headers:**      Destination header is mandatory!**      If header may be used.**      Depth header may be "0" or "infinity" (for collections, it MUST be "infinity")**      Overwrite header may be used*/PUBLIC BOOL HTMOVEDocumentAnchor (HTRequest * request,                                  HTAnchor * src,                                  HTParentAnchor * xmlbody,                                  HTDAVHeaders * headers) {    if (request && src && headers) {        /* set method and request-URI */        HTRequest_setMethod (request,METHOD_MOVE);        HTRequest_setAnchor (request,src);        HTTRACE (PROT_TRACE,"HTDAV.... Method set to MOVE\n");        /* set headers */        HTTRACE (PROT_TRACE,"HTDAV.... Seting default Headers \n");        HTRequest_addCacheControl (request,"no-cache","");        HTRequest_addGnHd (request,HT_G_PRAGMA_NO_CACHE);         /* WebDAV specific headers - Destination is mandatory! */        if (headers->Destination && *headers->Destination) {             HTTRACE (PROT_TRACE,"HTDAV.... Setting WebDAV headers \n");            HTRequest_addExtraHeader (request,"Destination",headers->Destination);            if (headers->If) /* If header may be used */                HTRequest_addExtraHeader (request,"If",headers->If);            if (headers->Overwrite != ' ') {                char over[] = { headers->Overwrite, '\0' };                HTRequest_addExtraHeader (request,"Overwirte", over );             }            if (headers->Depth) {                if (!strcasecomp (headers->Depth,"0") ||                     !strcasecomp (headers->Depth,"infinity"))                      HTRequest_addExtraHeader(request,"Depth",headers->Depth);            }        }         else return NO;                /* set body - if there is a body */        if (xmlbody) {            HTTRACE (PROT_TRACE,"HTDAV.... Setting Entity Body \n");            HTRequest_setEntityAnchor (request,xmlbody);             HTRequest_setPostCallback (request,HTEntity_callback);                      }               return HTLoad (request,NO);    }    return NO;  }PUBLIC BOOL HTMOVEAnchor (HTRequest * request,                           HTAnchor * src,                          const char * xmlbody,                          HTDAVHeaders * headers) {     if (request && src && headers) {        HTParentAnchor * body = NULL;        if (xmlbody) {            body = HTTmpAnchor (NULL);            HTAnchor_setDocument(body, (void *) xmlbody);            HTAnchor_setFormat (body, HTAtom_for ("text/xml"));            HTAnchor_setLength (body, strlen(xmlbody));        }            return HTMOVEDocumentAnchor (request,src,body,headers);    }    return NO;}/*** This MOVE request moves the resource indicated by an absolute URI** (parameter uri) to the URI in Destination header. */PUBLIC BOOL HTMOVEAbsolute (HTRequest * request,                            const char * uri,                            const char * xmlbody,                            HTDAVHeaders * headers) {    if (request && uri && *uri && headers) {        HTAnchor *src = HTAnchor_findAddress (uri);        return HTMOVEAnchor (request,src,xmlbody,headers);    }    return NO;}/*** This MOVE request moves the resource indicated by a relative URI,** which is made absolute by using the base anchor. */PUBLIC BOOL HTMOVERelative (HTRequest * request,                             const char * relative,                            HTParentAnchor * base,                            const char * xmlbody,                            HTDAVHeaders * headers) {    BOOL status = NO;    if (request && relative && base && headers) {         char * base_uri = HTAnchor_address ((HTAnchor *)base);         char * full_uri = HTParse (relative,base_uri,PARSE_ACCESS|PARSE_HOST| \                                                 PARSE_PATH|PARSE_PUNCTUATION);         status = HTMOVEAbsolute (request,full_uri,xmlbody,headers);         HT_FREE (full_uri);         HT_FREE (base_uri);    }    return status;}#endif /* HT_DAV */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -