Re: Files from FTP servers are transmitted as text

Ian Holsman <[email protected]>
Newsgroups gmane.comp.apache.mod-proxy
Message-ID <[email protected]>
On Thu, 2002-08-08 at 00:28, Alexey Panchenko wrote:
> Hi !

Hi Alexey.

I don't know if this is the correct fix for 2.0
if you have a multi-threaded server than old_type may be changed by a 
different thread.

maybe if we just remove 'old_type' altogether and just send out the type
command all the time ?

> 
> The function ftp_set_TYPE in proxy_ftp.c should be fixed.
> Now because of the static variable used correct type is set only once,
> and all subsequent file downloads use default type, resulting in
> corrupted files downloaded as text.
> 
> The simpliest fix is to remove comparision with old type value:
> 
>  /* Set ftp server to TYPE {A,I,E} before transfer of a directory or file */
>  static int ftp_set_TYPE(request_rec *r, BUFF *ctrl, char xfer_type)
>  {
>      static char old_type[2] = {'A', '\0'};      /* After logon, mode is ASCII */
>      int ret = HTTP_OK;
>      int rc;
>  
> -    if (xfer_type == old_type[0])  // remove these lines.
> -        return ret;
> -
>      /* set desired type */
>      old_type[0] = xfer_type;
>      ap_bvputs(ctrl, "TYPE ", old_type, CRLF, NULL);
>      ap_bflush(ctrl);
>      ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r->server, "FTP: TYPE %s", old_type);
> 
> -- 
> Best regards,
>  Alexey                          mailto:[email protected]
> 
-- 
Ian Holsman
Performance Measurement & Analysis
CNET Networks
PH: 415-344-2608
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.