curl-library
RE: Can't seem to transfer binary type
Date: Wed, 19 Jun 2002 00:23:11 +0200
I found the problem with the Text/Binary mixup.
I know that the command line compilation I have of the curl tool works. So
how could libcurl not work?
Since I'm using libcurl through the Perl module Curl::easy, I found that I
was downloading the file through a text-mode filehandle. As soon as I threw
in the line: "binmode(FILEHANDLE);" my problems were solved. I now get
downloads without corruption.
Thanks for helping me out, Daniel.
-----Original Message-----
From: Daniel Stenberg [mailto:daniel_at_haxx.se]
Sent: Tuesday, June 18, 2002 2:55 AM
To: Poulson, Shawn
Subject: RE: Can't seem to transfer binary type
On Mon, 17 Jun 2002, Poulson, Shawn wrote:
> Thanks again for your quick response.
Please don't take this off the list.
> What appears to me is that the TRANSFERTEXT option does work. However,
> there is an underlying filter that is doing the work. When I enable
> TRANSFERTEXT for ASCII, I get CRCRLF instead of CRLF when disabled.
Oh. How odd.
> I suspected your fopen()'s are using text mode. I inspected the source
and
> almost all the fopen's don't specify "b" for binary mode. So, instead of
> modifying everything there is a piece of info in MSDN that says you can
> link in "binmode.obj" as an easy way to set the default fopen to use
binary
> unless specified with mode "t". Alternatively you could set the global
var
> _fmode = _O_BINARY. I tried both but I still have the same problem.
Yes, when we download a file the fopen() of interest is the one in
my_fwrite_() in src/main.c and that one is already using "b" so I don't
think
this is the problem. Or perhaps I'm blind.
But you're right that it sounds as if it is some kind of problem similar to
this that occurs.
> CURLOPT_CRLF has no effect on my file output. Could this be the problem?
Not sure. I don't think you should use it anyway as you should use a binary
transfer and don't get any conversions at all.
> I'm having some difficulty following the source, so I cannot find this
> filter in the code.
The crlf filter is in lib/transfer.c, search for set.crlf and you'll find
it.
But you shouldn't be using that...
> Lastly, I don't think it's the FTP server. I'm running the server off a
> Red Hat 7.2 install, which has wu-ftpd. When I do a manual ftp client
> download to my win32 box with binary mode, I get the proper file and no
> corruption.
No, you're right, I don't think that ftp server does it wrong either.
-- Daniel Stenberg - http://daniel.haxx.se - +46-705-44 31 77 ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol ---------------------------------------------------------------------------- Bringing you mounds of caffeinated joy >>> http://thinkgeek.com/sf <<<Received on 2002-06-19