# HG changeset patch # User Mike Becker # Date 1444902066 -7200 # Node ID 8911170d5e78da0e170575602a707883110bfbf1 # Parent b66bed169fc3547c9a615bc2bad8b0ef364ac5bc fixed incorrect response buffer reset in manual redirection handling in do_propfind_request diff -r b66bed169fc3 -r 8911170d5e78 libidav/methods.c --- a/libidav/methods.c Thu Oct 15 11:05:27 2015 +0200 +++ b/libidav/methods.c Thu Oct 15 11:41:06 2015 +0200 @@ -48,9 +48,11 @@ { curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPFIND"); + // implement own redirection follower long follow = 0; curl_easy_getinfo(handle, CURLOPT_FOLLOWLOCATION, &follow); - int maxredirect = 16; + curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 0L); + const int maxredirect = 16; struct curl_slist *headers = NULL; CURLcode ret = 0; @@ -63,7 +65,6 @@ curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); - curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 0L); for(int i=0;i<=maxredirect;i++) { char *url = NULL; curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); @@ -83,13 +84,15 @@ } headers = curl_slist_append(headers, "Content-Type: text/xml"); curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); - - ucx_buffer_seek(request, 0, SEEK_SET); - ucx_buffer_seek(response, 0 , SEEK_SET); + + // reset buffers and perform request + request->pos = 0; + response->size = response->pos = 0; ret = curl_easy_perform(handle); curl_slist_free_all(headers); headers = NULL; + // continue work with URL we get from the server! char *location = NULL; curl_easy_getinfo(handle, CURLINFO_REDIRECT_URL, &location); if(location) {