curl-library
Re: using libcurl to invoke WebDAV methods on Exchange
Date: Wed, 21 Dec 2005 11:06:15 -0700
I gave this another go after upgrading to libcurl/7.15.1 OpenSSL/0.9.7a
zlib/1.1.4, but unfortunately the problem persists. Any ideas?
Andrew
Andrew Biggs wrote:
> Hello,
>
> I'm just starting off using libcurl, and I'm trying to use it to make
> WebDAV requests against a Microsoft Exchange server. Below I've
> included an HTTP request, an HTTP response, and the C++ code I use to
> generate these.
> The problem is that my CURLOPT_WRITEFUNCTION callback method is not
> being invoked when the HTTP response shown below is sent back by
> Exchange. I've used Ethereal to capture these messages, so I know the
> response shown below is in fact being sent.
>
> At the bottom of this message is the C++ code I used to generate this
> scenario. Note that when I run this, the "write_data has been
> called!" text never actually prints out, and breakpoints inside that
> function are never triggered. I'm building and running this on Linux
> FC4, and curl_version() returns: libcurl/7.10.6 OpenSSL/0.9.7a ipv6
> zlib/1.1.4.
>
> Please let me know if you have any ideas of what I may be doing wrong!
>
> Thanks,
> Andrew
>
> ============HTTP REQUEST===============
> SEARCH /exchange/adb/Contacts/ HTTP/1.1
> Authorization: Basic YXNwZW5cY3Vjc3ZjOkJvdWxkM3I=
> Host: 10.94.248.184
> Pragma: no-cache
> Accept: text/xml
> Depth: infinity
> Content-Type: text/xml
> Connection: Keep-Alive
> Content-Length: 229
>
> <?xml version="1.0"?><D:searchrequest xmlns:D="DAV:" ><D:sql>SELECT
> "http://schemas.microsoft.com/repl/contenttag" from SCOPE ('deep
> traversal of "/exchange/adb/Calendar/"') WHERE "DAV:isfolder" =
> True</D:sql></D:searchrequest>
> ============HTTP REQUEST===============
>
>
> ===========HTTP RESPONSE===============
> HTTP/1.1 207 Multi-Status
> Date: Tue, 20 Dec 2005 17:39:09 GMT
> Server: Microsoft-IIS/6.0
> X-Powered-By: ASP.NET
> Content-Type: text/xml
> Accept-Ranges: rows
> MS-WebStorage: 6.5.6944
> Transfer-Encoding: chunked
>
> a9
> <?xml version="1.0"?><a:multistatus
> xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
> xmlns:c="xml:" xmlns:d="http://schemas.microsoft.com/repl/"
> xmlns:a="DAV:"/>
> 0
> <crlf>
> ===========HTTP RESPONSE===============
>
>
>
> ============Main.cpp===================
> #include <iostream>
> #include <curl/curl.h>
> using namespace std;
>
> #define CHECKCC(x) \
> if ((cc = x) != CURLE_OK) { \
> cout << "Failed at line " << __LINE__ << " with code " << cc <<
> ". Exiting." << endl; \
> exit(1); \
> }
>
> size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
> {
> cout << endl << "*** write_data has been called! ***" << endl;
> return size*nmemb;
> }
> int main()
> { CURLcode cc;
> const char *url = "http://10.94.248.184/exchange/adb/Contacts/";
> const char *userpwd = "aspen\\cucsvc:Bould3r";
> const char *method = "SEARCH";
> curl_slist *slist = NULL;
> slist = curl_slist_append(slist, "Accept: text/xml");
> slist = curl_slist_append(slist, "Depth: infinity");
> slist = curl_slist_append(slist, "Content-Type: text/xml");
> slist = curl_slist_append(slist, "Connection: Keep-Alive");
> const char *postdata =
> "<?xml version=\"1.0\"?><D:searchrequest xmlns:D=\"DAV:\" >"
> "<D:sql>SELECT \"http://schemas.microsoft.com/repl/contenttag\""
> " from SCOPE ('deep traversal of \"/exchange/adb/Calendar/\"') "
> "WHERE \"DAV:isfolder\" = True</D:sql></D:searchrequest>\r\n";
> CHECKCC(curl_global_init(CURL_GLOBAL_SSL))
> CURL *pcurl = curl_easy_init();
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_VERBOSE, 1))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_URL, url))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_CUSTOMREQUEST, method))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_HTTPHEADER, slist))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_POSTFIELDS, postdata))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_POSTFIELDSIZE,
> strlen(postdata)))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_USERPWD, userpwd))
> CHECKCC(curl_easy_setopt(pcurl, CURLOPT_WRITEFUNCTION, write_data))
> CHECKCC(curl_easy_perform(pcurl))
> curl_slist_free_all(slist);
> curl_global_cleanup();
> } ===========Main.cpp===============
>
Received on 2005-12-21