cURL / Mailing Lists / curl-library / Single Mail


how to define which protocal to use...

From: Olli Aalto <>
Date: Mon, 17 Sep 2001 13:10:02 +0300


I have bit of a problem uploading a file to a ftp-server. It seems that
curllib wants to use http protocol. How do I define which protocol to

I'll put my test programs source code here and the stuff I get on screen.

#include <stdio.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
int main(int argc, char **argv)
  CURL *curl;
  CURLcode res;
  FILE *infile;
  char *userpasswd = "olli";
  char errors[256];
  infile = fopen("README", "r");
  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
    curl_easy_setopt(curl, CURLOPT_INFILE, infile);
    curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1);
    curl_easy_setopt(curl, CURLOPT_USERPWD, userpasswd);
    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errors);
    curl_easy_setopt(curl, CURLOPT_URL, "");
    res = curl_easy_perform(curl);
    printf("%d\n", res);
    printf("%s\n", errors);
    /* always cleanup */
  return 0;

Here's what I get:

[olli_at_lit ~/c]$ ./curltest
500 'PUT /README HTTP/1.1': command not understood.
500 'AUTHORIZATION: Basic b2xsaTp5MmtydWxlcw==': command not understood.
500 'HOST:': command not understood.
500 'PRAGMA: no-cache': command not understood.
500 'ACCEPT: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*': command
not understood.
500 '': command not understood.
500 'DKLFJSDLKFJSLDKFJ': command not understood.

I'll have to use ctrl-c to exit.

I'm using linux 2.4.2(redhat 7.1) on i386. I have curl 7.8.1.

Btw. if I change the line
    curl_easy_setopt(curl, CURLOPT_URL, "");
    curl_easy_setopt(curl, CURLOPT_URL, "");
I'll get error number 7, connection refused.


Olli Aalto                                     Fimeko-Data Oy
Sun Certified System Administrator             Phone: +358-(0)9-477 02636
--< Dumb Packing Labels >--
On a bottle of Palmolive Dishwashing liquid:
"Do not use on food."
(Hey, Mom, we're out of syrup! It's OK honey just grab the Palmolive!)
Received on 2001-09-17