cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re: Issue with <CR> being appended in a FTP transfer

From: Uday Singh <usingh_at_yahoo.com>
Date: Mon, 3 Feb 2003 11:36:01 -0800 (PST)

Hi Daniel,

Thank you for the quick response. I am using libcurl, more as a http and ftp
client, than just as a single URL access lib.

That is why I am using the (CURLOPT_CUSTOMREQUEST, "RETR <File-name>"). As the
URL that I opened the session with will be different from the the files that I
want to access from a given FTP server (or directory). I have wrappers to MKD,
CWD, RNFR-RNTO, etc...

From your previous mail, I tried fetching a file by setting the full URL (using
CURLOPT_URL) and the file I got back didn't have any carriage returns. That
works for me!!! Great. Thank you.

Just to explain the issue that I was having:
1. I would set the CURLOPT_URL to ftp://host:21.
2. As I was trying to grab all the files in the directory /dir1, I would using
CURLOPT_CUSTOMREQUEST.
3. I would send in (CURLOPT_CUSTOMREQUEST, "RETR /dir1/file1.txt") and so on.
4. Then call curl_easy_perform();
5. The steps #3 and #4 would work and I would get the file back. But the would
contain extra CR (\r) for each newline. In my sample file on the server, there
were two lines. The file on server didn't contain any CRs. But the file I got
back would have two CRs for each of the new lines.

Thank you for you help and quick response. Right now I am in a crunch mode, but
when I get some free time I would sure like to contribute to your code base.

- Uday

============================================
> I am trying to get a file from a FTP location.
> I use the curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "RETR <file-name>");

Uh, why do you set this? RETR is the normal download command.

> The file I get back has carriage return (\r). I would ideally like to get
> the file as-is without any modification.

Has carriage return where? In the contents? And you say the original file on
the server doesn't have this?

> I tried setting the mode to ASCII (CURLOPT_TRANFERTEXT set to non-null).
> That didn't fix it.

That tells the server to send it as ASCII, and it could affect newline
translations etc, sure.

> I tried calling "TYPE I" (to set the mode to binary) through the curl_slist
> using the CURLOPT_PREQUOTE option. That didn't seem to makea difference.

libcurl uses TYPE I by default unless you set it to do ASCII.

> Is there something obvious that I am missing? Any advice you may have to
> offer will be great.

I don't understand what you're trying to do. libcurl gets the file using the
FTP protocol. I think you're trying to do some translations of file contents
that the FTP protocol doesn't do automaticly for you.

=====

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
Received on 2003-02-03