cURL / Mailing Lists / curl-library / Single Mail

curl-library

how to define which protocal to use...

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

Hi!

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
use.

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, "fani.fidata.fi:21/README");
    res = curl_easy_perform(curl);
    printf("%d\n", res);
    printf("%s\n", errors);
 
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
  return 0;
}

Here's what I get:

[olli_at_lit ~/c]$ ./curltest
password:
500 'PUT /README HTTP/1.1': command not understood.
500 'AUTHORIZATION: Basic b2xsaTp5MmtydWxlcw==': command not understood.
500 'HOST: fani.fidata.fi:21': 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, "fani.fidata.fi:21/README");
to
    curl_easy_setopt(curl, CURLOPT_URL, "fani.fidata.fi/README");
I'll get error number 7, connection refused.

O.

--
Olli Aalto                                     Fimeko-Data Oy
Sun Certified System Administrator             Phone: +358-(0)9-477 02636
                                               http://www.fidata.fi
--< 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