lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LYNX-DEV Patch for Proxy Server / FTP problem


From: Klaus Weide
Subject: LYNX-DEV Patch for Proxy Server / FTP problem
Date: Wed, 19 Feb 1997 23:23:24 -0600 (CST)

On Wed, 19 Feb 1997, Rob Worman wrote:
[ to me, instead of the list ]

> Subject: Re: LYNX-DEV Lynx 2.6 / Proxy Server / FTP problem
> 
> ~~I connect to an FTP site (e.g. ftp.cdrom.com) fine at first, but when I try
> ~~to cd into another directory (like /pub) I get an error from the proxy
> ~~server, saying "too many redirects"
> ~~
> ~~If I use Netscape to do this, the proxy server gives me no such error.
> ~~
> ========
> 
> here is some more info (thanks for the response)
> 
> 1 - proxy server is netscape's, v2.5 (solaris 2.5.1)
> 2 - if I lynx to the FTP site directly, no problem
> 3 - if I lynx to the site via the proxy server, it happens
> 4 - netscape was definitely using the proxy, (with no such problems)
> 5 - the proxy server was definitely configured the same way between 4 and 5


The problem is that the Netscape proxy sends a HTTP redirection in some
cases, which instructs the browser to repeat the request with a different
URL.  For example:

[ the request: ]
GET ftp://ftp.aol.com/pub HTTP/1.0

[ headers from the reponse: ]
HTTP/1.0 302 Found
Proxy-agent: Netscape-Proxy/2.5
Date: Thu, 20 Feb 1997 05:00:59 GMT
Location: ftp://ftp.aol.com/pub/
Content-type: text/html
Content-length: 208

(This is a wasteful methods and should not be necessary for an FTP gateway,
but I guess Netscape is an Intranet company now, so a few unnecessary
packets don't matter :( )

So ftp://ftp.aol.com/pub is redirected to ftp://ftp.aol.com/pub/, note
the trailing slash.  But before Lynx retries to access the new URL,
it will (unfortunately and erroneously) "simplify" the new URL by removing
the final slash, so it looks like the original one, and we have a loop
(which Lynx detects after some iterations).

The patches below (for *Lynx 2.7*) should correct that.  The 
stripping-off-of-final-slash shouldn't be needed even when the internal
FTP gateway is used (instead of a proxy), but I couldn't be sure whether
that is true in all cases (/foo/... hack etc...).  Also if the final
slash is not removed from an URL like ftp://ftp.aol.com/pub/, the internal
gateway doesn't insert an "Up to <parent directory" link.  So, to be
conservative, a final slash is only left in place if the URL will be
accessed through a proxy.

  Klaus

*** lynx2-7/WWW/Library/Implementation/HTAccess.h~      Wed Dec  6 08:46:10 1995
--- lynx2-7/WWW/Library/Implementation/HTAccess.h       Wed Feb 19 22:24:48 1997
***************
*** 93,98 ****
--- 93,115 ----
  extern HTFormat HTOutputFormat;         /* To convert on load, set this */
  
  
+ /*    Check for proxy override.                       override_proxy()
+ **
+ **    Check the no_proxy environment variable to get the list
+ **    of hosts for which proxy server is not consulted.
+ **
+ **    no_proxy is a comma- or space-separated list of machine
+ **    or domain names, with optional :port part.  If no :port
+ **    part is present, it applies to all ports on that domain.
+ **
+ **  Example:
+ **          no_proxy="cern.ch,some.domain:8001"
+ **
+ **  Use "*" to override all proxy service:
+ **         no_proxy="*"
+ */
+ extern BOOL override_proxy PARAMS((
+       CONST char *    addr));
  
  /*
  
*** lynx2-7/WWW/Library/Implementation/HTAccess.c~      Sun Feb  9 03:48:46 1997
--- lynx2-7/WWW/Library/Implementation/HTAccess.c       Wed Feb 19 22:22:30 1997
***************
*** 200,206 ****
  **  Use "*" to override all proxy service:
  **         no_proxy="*"
  */
! PRIVATE BOOL override_proxy ARGS1(
        CONST char *,   addr)
  {
      CONST char * no_proxy = getenv("no_proxy");
--- 200,206 ----
  **  Use "*" to override all proxy service:
  **         no_proxy="*"
  */
! PUBLIC BOOL override_proxy ARGS1(
        CONST char *,   addr)
  {
      CONST char * no_proxy = getenv("no_proxy");
*** lynx2-7/src/LYGetFile.c.~1~ Sun Feb  9 04:37:54 1997
--- lynx2-7/src/LYGetFile.c     Wed Feb 19 22:22:25 1997
***************
*** 1056,1061 ****
--- 1056,1062 ----
       */
      if (!strncmp(doc->address, "ftp", 3) &&
          doc->address[strlen(doc->address)-1] == '/') {
+         char * proxy;
        char *path = HTParse(doc->address, "", PARSE_PATH|PARSE_PUNCTUATION);
        if (path) {
            if (path[0] == '/' && path[1] == '\0') {
***************
*** 1066,1075 ****
        }
        if (TRACE)
            fprintf(stderr,"LYGetFile: URL %s\n", doc->address);
!       doc->address[strlen(doc->address)-1] = '\0';
!       if (TRACE) {
            fprintf(stderr,"    changed to %s\n", doc->address);
            sleep(MessageSecs);
        }
      }
  
--- 1067,1091 ----
        }
        if (TRACE)
            fprintf(stderr,"LYGetFile: URL %s\n", doc->address);
! 
!       /* DON'T trim endling slash if we will retrieve through a proxy.
!          It confuses things with Netscape's proxy (which may send
!          HTTP redirections), and probably other proxies, too.
!          Unfortunately we have to parse the ftp_proxy and no_proxy
!          environment variables, which will be done again in HTAccess.c
!          -kw */
!       if ((proxy=(char *)getenv("ftp_proxy")) && *proxy &&
!           !override_proxy(doc->address)) {
!         if (TRACE) {
!           fprintf(stderr,"NOT changed - will use proxy %s\n", proxy);
!           sleep(MessageSecs);
!         }
!       } else {
!         doc->address[strlen(doc->address)-1] = '\0';
!         if (TRACE) {
            fprintf(stderr,"    changed to %s\n", doc->address);
            sleep(MessageSecs);
+         }
        }
      }
  



;
; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.
;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]