httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org (Ralf S. Engelschall)
Subject cvs commit: apache-1.3/src/modules/proxy proxy_ftp.c
Date Fri, 20 Mar 1998 09:11:15 GMT
rse         98/03/20 01:11:15

  Modified:    .        STATUS
               src      CHANGES
               src/modules/proxy proxy_ftp.c
  Log:
  The proxy module now uses the already determined response of
  the FTP SITE command to provide a Content-Length header for FTP requests.
  
  Submitted by: Ralf S. Engelschall
  PR#: 1183
  
  Revision  Changes    Path
  1.200     +2 -1      apache-1.3/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/STATUS,v
  retrieving revision 1.199
  retrieving revision 1.200
  diff -u -r1.199 -r1.200
  --- STATUS	1998/03/20 07:56:47	1.199
  +++ STATUS	1998/03/20 09:11:06	1.200
  @@ -99,7 +99,8 @@
       * Ralf's additional manual pages for the support programs
       * Ben Hyde's Configure check for unknown command switch
       * Martin's fix for src/helpers/fp2rp
  -    * Ralf's reanimation of an undocumented directive: ProxyReceiveBufferSize
  +    * Ralf's reanim. of (undocumented) directive: ProxyReceiveBufferSize, PR#1348
  +    * Ralf's mod_proxy fix to use FTP SIZE response for Content-Length, PR#1183
   
   Available Patches:
   
  
  
  
  1.726     +4 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.725
  retrieving revision 1.726
  diff -u -r1.725 -r1.726
  --- CHANGES	1998/03/20 07:56:51	1.725
  +++ CHANGES	1998/03/20 09:11:12	1.726
  @@ -1,5 +1,9 @@
   Changes with Apache 1.3b6
   
  +  *) Now mod_proxy uses the reponse string (in addition to the response status
  +     code) from the already used FTP SIZE command to setup the Content-Length
  +     header if available. [Ralf S. Engelschall, PR#1183]
  +
     *) Reanimated the (still undocumented) proxy receive buffer size directive:
        Renamed from ReceiveBufferSize to ProxyReceiveBufferSize because the old
        name was really too generic, added documentation for this directive to
  
  
  
  1.52      +59 -2     apache-1.3/src/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- proxy_ftp.c	1998/03/20 07:56:55	1.51
  +++ proxy_ftp.c	1998/03/20 09:11:14	1.52
  @@ -213,6 +213,47 @@
       return status;
   }
   
  +/*
  + * Like ftp_getrc but returns both the ftp status code and 
  + * remembers the response message in the supplied buffer
  + */
  +static int ftp_getrc_msg(BUFF *f, char *msgbuf, int msglen)
  +{
  +    int len, status;
  +    char linebuff[100], buff[5];
  +    char *mb = msgbuf;
  +    int ml = msglen;
  +
  +    len = bgets(linebuff, 100, f);
  +    if (len == -1)
  +	return -1;
  +    if (len < 5 || !isdigit(linebuff[0]) || !isdigit(linebuff[1]) ||
  +	!isdigit(linebuff[2]) || (linebuff[3] != ' ' && linebuff[3] != '-'))
  +	status = 0;
  +    else
  +	status = 100 * linebuff[0] + 10 * linebuff[1] + linebuff[2] - 111 * '0';
  +
  +    mb = ap_cpystrn(mb, linebuff+4, len-4 < ml ? len-4 : ml);
  +
  +    if (linebuff[len - 1] != '\n')
  +	(void)bskiplf(f);
  +
  +    if (linebuff[3] == '-') {
  +	memcpy(buff, linebuff, 3);
  +	buff[3] = ' ';
  +	do {
  +	    len = bgets(linebuff, 100, f);
  +	    if (len == -1)
  +		return -1;
  +	    if (linebuff[len - 1] != '\n') {
  +		(void)bskiplf(f);
  +	    }
  +            mb = ap_cpystrn(mb, linebuff+4, len-4 < ml ? len-4 : ml);
  +	} while (memcmp(linebuff, buff, 4) != 0);
  +    }
  +    return status;
  +}
  +
   static long int send_dir(BUFF *f, request_rec *r, BUFF *f2, struct cache_req *c, char *url)
   {
       char buf[IOBUFSIZE];
  @@ -441,11 +482,20 @@
       char pasv[64];
       char *pstr;
   
  +/* stuff for responses */
  +    char *resp;
  +    int resplen;
  +    char *size = NULL;
  +
   /* we only support GET and HEAD */
   
       if (r->method_number != M_GET)
   	return NOT_IMPLEMENTED;
   
  +/* allocate a buffer for the response message */
  +	resplen = MAX_STRING_LEN;
  +	resp = (char *)palloc(r->pool, resplen);
  +
   /* We break the URL into host, port, path-search */
   
       host = pstrdup(p, url + 6);
  @@ -833,8 +883,8 @@
   	bputs(CRLF, f);
   	bflush(f);
   	Explain1("FTP: SIZE %s", path);
  -	i = ftp_getrc(f);
  -	Explain1("FTP: returned status %d", i);
  +	i = ftp_getrc_msg(f, resp, resplen);
  +	Explain2("FTP: returned status %d with response %s", i, resp);
   	if (i != 500) {		/* Size command not recognized */
   	    if (i == 550) {	/* Not a regular file */
   		Explain0("FTP: SIZE shows this is a directory");
  @@ -861,6 +911,9 @@
   		path = "";
   		len = 0;
   	    }
  +	    else if (i == 213) { /* Size command ok */
  +	        size = resp;
  +	    }
   	}
       }
   
  @@ -935,6 +988,10 @@
   	}
   	else {
   	    proxy_add_header(resp_hdrs, "Content-Type", "text/plain", HDR_REP);
  +	}
  +	if (size != NULL) {
  +	    proxy_add_header(resp_hdrs, "Content-Length", size, HDR_REP);
  +	    Explain1("FTP: Content-Length set to %s", size);
   	}
       }
   
  
  
  

Mime
View raw message