cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_URL always lists

From: Anders Havn <anders.havn_at_gmail.com>
Date: Mon, 21 May 2012 18:47:55 +0200

Hi,

I'm just wondering if I'm doing something wrong or this is just how it
works. I always set CURLOPT_URL to my base url, but then it also
always lists the files and folders in the base url.
This is how my codes looks when I delete a file:

NSString username = @"username";
NSString password = @"password";
NSString* filePath = @"rm /UserFolder/Test.txt";
NSString* baseUrl = @"sftp://myftpserver.org";

struct curl_slist* headerlist = curl_slist_append(NULL, [filePath
cStringUsingEncoding:encoding]);
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, [baseUrl cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_USERNAME, [username
cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_PASSWORD, [password
cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerList);
CURLcode result = curl_easy_perform(curl);
curl_slist_free_all (headerList);
curl_easy_cleanup(curl);

With this code I can see in the output windows (when debugging) that
it lists the folder in the base url.

If I leave out the call to CURLOPT_URL and specify the whole path in
the headerlist then it doesn't work:

NSString username = @"username";
NSString password = @"password";
NSString* filePath = @"rm sftp://myftpserver.org/UserFolder/Test.txt";

struct curl_slist* headerlist = curl_slist_append(NULL, [filePath
cStringUsingEncoding:encoding]);
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_USERNAME, [username
cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_PASSWORD, [password
cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerList);
CURLcode result = curl_easy_perform(curl);
curl_slist_free_all (headerList);
curl_easy_cleanup(curl);

Thank you for you help.

Best Regards,
Anders Havn
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-05-21