lynx-dev
[Top][All Lists]
Advanced

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

Re: LYNX-DEV Getting proxies to work


From: Alex Lyons A32/373-Winfrith Tel2368 FAX2508
Subject: Re: LYNX-DEV Getting proxies to work
Date: Fri, 9 May 97 16:02:24 BST

Gee folks, it's great to be popular - I feel like Tony Blair
(UK-specific reference).

By popular demand here are the mods to HTTP.c and HTAABrow.c in
libwww-FM that I've made to enable proxy authorisation.  These are
given in "diff -c" form.  Note that they refer to the version of
libwww-FM that came with lynx 2.7, not 2.7.1 : I haven't checked
whether the files are the same in the newer release.

Alex.


*** HTTP.c.org  Fri May  9 15:38:03 1997
--- HTTP.c      Fri May  9 15:35:05 1997
***************
*** 3,8 ****
--- 3,9 ----
  ** Modified:
  ** 27 Jan 1994  PDM  Added Ari Luotonen's Fix for Reload when using proxy
  **                   servers.
+ ** 28 Apr 1997  AJL  Do Proxy Authorisation.
  */
  
  #include "HTUtils.h"
***************
*** 50,55 ****
--- 51,57 ----
  extern BOOL LYSetCookies;     /* Act on Set-Cookie headers? */
  
  extern BOOL using_proxy;      /* Are we using an HTTP gateway? */
+ PUBLIC BOOL auth_proxy;               /* Generate a proxy authentication -AJL 
*/
  PUBLIC BOOL reloading = FALSE;        /* Reloading => send no-cache pragma to 
proxy */
  PUBLIC char * redirecting_url = NULL;     /* Location: value. */
  PUBLIC BOOL permanent_redirection = FALSE;  /* Got 301 status? */
***************
*** 394,426 ****
        **  Add 'Cookie:' header, if applicable.
        */
        if (using_proxy) {
            /*
!           **  If it's not an HTTP or HTTPS document being proxied,
!           **  forget about cookies.
            */
            if (!strncmp(docname, "http", 4)) {
!               char *host2 = NULL, *path2 = NULL;
!               int port = (strncmp(docname, "https", 5) ?
!                                              HTTP_PORT : HTTPS_PORT);
! 
!               host2 = HTParse(docname, "", PARSE_HOST);
!               path2 = HTParse(docname, "", PARSE_PATH|PARSE_PUNCTUATION);
!               if (host2) {
!                   if ((colon = strchr(host2, ':')) != NULL) {
!                       /*
!                       **  Use non-default port number.
!                       */
!                       *colon = '\0';
!                       colon++;
!                       port = atoi(colon);
!                   }
!               }
!               cookie = LYCookie(host2, path2, port, secure);
!               FREE(host2);
!               FREE(path2);
            }
        } else {
            cookie = LYCookie(hostname, abspath, portnumber, secure);
        }
        if (cookie != NULL) {
            if (*cookie != '\0') {
--- 396,461 ----
        **  Add 'Cookie:' header, if applicable.
        */
        if (using_proxy) {
+           char *host2 = NULL, *path2 = NULL;
+           int port2 = (strncmp(docname, "https", 5) ?
+                                          HTTP_PORT : HTTPS_PORT);
+           host2 = HTParse(docname, "", PARSE_HOST);
+           path2 = HTParse(docname, "", PARSE_PATH|PARSE_PUNCTUATION);
+           if (host2) {
+               if ((colon = strchr(host2, ':')) != NULL) {
+                   /* Use non-default port number */
+                   *colon = '\0';
+                   colon++;
+                   port2 = atoi(colon);
+               }
+           }
+           auth_proxy = NO;  /* this composeAuth does file access  -AJL */
+           if ((auth = HTAA_composeAuth(host2, port2, path2)) != NULL &&
+               *auth != '\0') {
+               /*
+               **  If auth is not NULL nor zero-length, it's
+               **  an Authorization header to be included. - FM
+               */ 
+               sprintf(line, "%s%c%c", auth, CR, LF);
+               StrAllocCat(command, line);
+               if (TRACE)
+                   fprintf(stderr, "HTTP: Sending authorization: %s\n", auth);
+           } else if (auth && *auth == '\0') {
+               /*
+               **  If auth is a zero-length string, the user either
+               **  cancelled or goofed at the username and password
+               **  prompt. - FM
+               */
+               if (!(traversal || dump_output_immediately) &&
+                       HTConfirm("Proceed without a username and password?")) {
+                   show_401 = TRUE;
+               } else {
+                   if (traversal || dump_output_immediately)
+                       HTAlert("Can't proceed without a username and 
password.");
+                   FREE(command);
+                   FREE(hostname);
+                   FREE(docname);
+                   FREE(host2);
+                   FREE(path2);
+                   status = HT_NOT_LOADED;
+                   goto done;
+               }
+           } else {
+               if (TRACE)
+                   fprintf(stderr, "HTTP: Not sending authorization (yet)\n");
+           }
            /*
!           **  Add 'Cookie:' header, if it's HTTP or HTTPS document being 
proxied.
            */
            if (!strncmp(docname, "http", 4)) {
!               cookie = LYCookie(host2, path2, port2, secure);
            }
+           FREE(host2);
+           FREE(path2);
+           auth_proxy = YES;  /* next composeAuth does proxy  -AJL */
        } else {
            cookie = LYCookie(hostname, abspath, portnumber, secure);
+           auth_proxy = NO;
        }
        if (cookie != NULL) {
            if (*cookie != '\0') {
***************
*** 443,449 ****
              sprintf(line, "%s%c%c", auth, CR, LF);
              StrAllocCat(command, line);
            if (TRACE)
!                 fprintf(stderr, "HTTP: Sending authorization: %s\n", auth);
        } else if (auth && *auth == '\0') {
            /*
            **  If auth is a zero-length string, the user either
--- 478,484 ----
              sprintf(line, "%s%c%c", auth, CR, LF);
              StrAllocCat(command, line);
            if (TRACE)
!                 fprintf(stderr, "HTTP: Sending (proxy) authorization: %s\n", 
auth);
        } else if (auth && *auth == '\0') {
            /*
            **  If auth is a zero-length string, the user either
***************
*** 464,470 ****
            }
          } else {
            if (TRACE)
!                 fprintf(stderr, "HTTP: Not sending authorization (yet)\n");
          }
          FREE(hostname);
          FREE(docname);
--- 499,505 ----
            }
          } else {
            if (TRACE)
!                 fprintf(stderr, "HTTP: Not sending (proxy) authorization 
(yet)\n");
          }
          FREE(hostname);
          FREE(docname);
***************
*** 1229,1234 ****
--- 1264,1270 ----
                 *  to show the 401 body or restore the current
                 *  document. - FM
                 */
+               auth_proxy = NO;
                if (show_401)
                    break;
                if (HTAA_shouldRetryWithAuth(start_of_data, length,
***************
*** 1271,1287 ****
  
              case 407:
                /*
!                *  Proxy Authentication Required.  We'll handle
!                *  Proxy-Authenticate headers and retry with a
!                *  Proxy-Authorization header, someday, but for
!                *  now, apologized to the user and restore the
!                *  current document. - FM
                 */
!               HTAlert(
!                "Proxy Authentication Required.  Sorry, not yet supported.");
!                 HTTP_NETCLOSE(s, handle);
!               status = HT_NO_DATA;
!               goto done;
                break;
  
              case 408:
--- 1307,1362 ----
  
              case 407:
                /*
!                *  GO ON, IT'S NOT THAT DIFFICULT! -AJL
!                *  (mainly copied from 401 case)
!                *  Authorization for proxy server required.
!                *  If show_401 is set, proceed to showing the
!                *  407 body.  Otherwise, if we can set up
!                *  authorization based on the Proxy-Authenticate
!                *  header, and the user provides a username and
!                *  password, try again.  Otherwise, check whether
!                *  to show the 401 body or restore the current
!                *  document. - FM
                 */
!               auth_proxy = YES;
!               if (show_401)
!                   break;
!               if (HTAA_shouldRetryWithAuth(start_of_data, length,
!                                            (void *)handle, s)) {
!                   extern char *authentication_info[2];
! 
!                     HTTP_NETCLOSE(s, handle);
!                     if (dump_output_immediately && !authentication_info[0]) {
!                         fprintf(stderr,
!                               "HTTP: Proxy authorization required.\n");
!                         fprintf(stderr,
!                               "       Use the -auth=id:pw parameter.\n");
!                         status = HT_NO_DATA;
!                         goto clean_up;
!                     }
! 
!                     if (TRACE) 
!                         fprintf(stderr, "%s %d %s\n",
!                               "HTTP: close socket", s,
!                               "to retry with Proxy Authorization");
! 
!                     _HTProgress (
!                       "Retrying with proxy authorization information.");
!                   FREE(line_buffer);
!                   FREE(line_kept_clean);
!                     goto try_again;
!                     break;
!               } else if (!(traversal || dump_output_immediately) &&
!                          HTConfirm("Show the 407 message body?")) {
!                   break;
!                 } else {
!                   if (traversal || dump_output_immediately)
!                       HTAlert(
!       "Can't retry with proxy authorization!  Contact the server's 
WebMaster.");
!                   HTTP_NETCLOSE(s, handle);
!                     status = -1;
!                     goto clean_up;
!               }
                break;
  
              case 408:
*** HTAABrow.c.org      Fri May  9 15:37:39 1997
--- HTAABrow.c  Fri May  9 15:30:02 1997
***************
*** 42,47 ****
--- 42,50 ----
  **                    otherwise HTUU_encode() reads uninitialized memory
  **                    every now and then (not a real bug but not pretty).
  **                    Corrected the formula for uuencode destination size.
+ **
+ ** 28 Apr 1997        AJL     Do Proxy Authorisation.
+ **
  ** BUGS:
  **
  **
***************
*** 61,66 ****
--- 64,70 ----
  #include "LYLeaks.h"
  
  extern BOOL using_proxy;      /* Are we using an HTTP gateway? */
+ extern BOOL auth_proxy;               /* Generate a proxy authorisation -AJL 
*/
  
  /*
  **  Local datatype definitions
***************
*** 125,131 ****
--- 129,140 ----
  PRIVATE char *HTAAForwardAuth = NULL; /* Authorization: line to forward    */
                                          /* (used by gateway httpds)        */
  
+ PRIVATE HTAASetup *proxy_setup= NULL; /* Same as above, but for Proxy -AJL */
+ PRIVATE char *proxy_hostname  = NULL;
+ PRIVATE char *proxy_docname   = NULL;
+ PRIVATE int proxy_portnumber  = 80;
  
+ 
  /*** HTAAForwardAuth for enabling gateway-httpds to forward Authorization ***/
  
  PUBLIC void HTAAForwardAuth_set ARGS2(CONST char *, scheme_name,
***************
*** 583,589 ****
                     setup->server->hostname : "??") + 40;
        if (!(msg = (char*)calloc(1, sizeof(char) * len)))
            outofmem(__FILE__, "compose_auth_string");
!       if (using_proxy && setup->template) {
            proxiedHost = HTParse(setup->template, "", PARSE_HOST);
            if (proxiedHost && *proxiedHost != '\0') {
                theHost = proxiedHost;
--- 592,598 ----
                     setup->server->hostname : "??") + 40;
        if (!(msg = (char*)calloc(1, sizeof(char) * len)))
            outofmem(__FILE__, "compose_auth_string");
!       if ((!auth_proxy) && using_proxy && setup->template) {
            proxiedHost = HTParse(setup->template, "", PARSE_HOST);
            if (proxiedHost && *proxiedHost != '\0') {
                theHost = proxiedHost;
***************
*** 737,744 ****
  
      HTAAForwardAuth_reset();
      FREE(HTAA_composeAuthResult);
!     FREE(current_hostname);
!     FREE(current_docname);
      FREE(compose_auth_stringResult);
      FREE(secret_key);
  }
--- 746,758 ----
  
      HTAAForwardAuth_reset();
      FREE(HTAA_composeAuthResult);
!     if (auth_proxy) {
!       FREE(proxy_hostname);
!       FREE(proxy_docname);
!     } else {
!       FREE(current_hostname);
!       FREE(current_docname);
!     }
      FREE(compose_auth_stringResult);
      FREE(secret_key);
  }
***************
*** 799,877 ****
  
      FREE(HTAA_composeAuthResult);     /* From previous call */
  
!     if (TRACE)
!       fprintf(stderr, 
!               "Composing Authorization for %s:%d/%s\n",
!               hostname, portnumber, docname);
  
!     if (current_portnumber != portnumber ||
!       !current_hostname || !current_docname ||
!       !hostname         || !docname         ||
!       0 != strcmp(current_hostname, hostname) ||
!       0 != strcmp(current_docname, docname)) {
! 
!       retry = NO;
! 
!       current_portnumber = portnumber;
        
!       if (hostname)
!           StrAllocCopy(current_hostname, hostname);
!       else
!           FREE(current_hostname);
! 
!       if (docname)
!           StrAllocCopy(current_docname, docname);
!       else
!           FREE(current_docname);
!     } else {
!         retry = YES;
!     }
      
!     if (!current_setup || !retry)
!       current_setup = HTAASetup_lookup(hostname, portnumber, docname);
! 
!     if (!current_setup)
!       return NULL;
! 
! 
!     switch (scheme = HTAA_selectScheme(current_setup)) {
!       case HTAA_BASIC:
!       case HTAA_PUBKEY:
!       auth_string = compose_auth_string(scheme, current_setup);
!       break;
!       case HTAA_KERBEROS_V4:
!       /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */
!       default:
!       {
!           char msg[100];
!           sprintf(msg, "%s %s `%s'",
!                   "This client doesn't know how to compose authentication",
!                   "information for scheme", HTAAScheme_name(scheme));
!           HTAlert(msg);
!           auth_string = NULL;
        }
!     } /* switch scheme */
  
!     current_setup->retry = NO;
  
!     if (!auth_string)
!         /*
!        *  Signal a failure. - FM
!        */
!       return NULL;  /* Added by marca. */
!     if (*auth_string == '\0') {
!         /*
!        *  Signal an abort. - FM
!        */
!         StrAllocCopy(HTAA_composeAuthResult, "");
!       return(HTAA_composeAuthResult);
!     }
      
!     len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 20;
!     if (!(HTAA_composeAuthResult =
!               (char*)calloc(1, sizeof(char) * len)))
!       outofmem(__FILE__, "HTAA_composeAuth");
!     strcpy(HTAA_composeAuthResult, "Authorization: ");
      strcat(HTAA_composeAuthResult, HTAAScheme_name(scheme));
      strcat(HTAA_composeAuthResult, " ");
      strcat(HTAA_composeAuthResult, auth_string);
--- 813,966 ----
  
      FREE(HTAA_composeAuthResult);     /* From previous call */
  
!     if (auth_proxy) { /* Proxy Authorisation required -AJL */
  
!       if (TRACE)
!           fprintf(stderr, 
!                   "Composing Proxy Authorization for %s:%d/%s\n",
!                   hostname, portnumber, docname);
!     
!       if (proxy_portnumber != portnumber ||
!           !proxy_hostname || !proxy_docname ||
!           !hostname         || !docname         ||
!           0 != strcmp(proxy_hostname, hostname) ||
!           0 != strcmp(proxy_docname, docname)) {
!     
!           retry = NO;
!     
!           proxy_portnumber = portnumber;
!           
!           if (hostname)
!               StrAllocCopy(proxy_hostname, hostname);
!           else
!               FREE(proxy_hostname);
!     
!           if (docname)
!               StrAllocCopy(proxy_docname, docname);
!           else
!               FREE(proxy_docname);
!       } else {
!           retry = YES;
!       }
        
!       if (!proxy_setup || !retry)
!           proxy_setup = HTAASetup_lookup(hostname, portnumber, docname);
      
!       if (!proxy_setup)
!           return NULL;
!     
!       switch (scheme = HTAA_selectScheme(proxy_setup)) {
!         case HTAA_BASIC:
!         case HTAA_PUBKEY:
!           auth_string = compose_auth_string(scheme, proxy_setup);
!           break;
!         case HTAA_KERBEROS_V4:
!           /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */
!         default:
!           {
!               char msg[100];
!               sprintf(msg, "%s %s `%s'",
!                       "This client doesn't know how to compose proxy 
authentication",
!                       "information for scheme", HTAAScheme_name(scheme));
!               HTAlert(msg);
!               auth_string = NULL;
!           }
!       } /* switch scheme */
!     
!       proxy_setup->retry = NO;
!     
!       if (!auth_string)
!           /*
!            *  Signal a failure. - FM
!            */
!           return NULL;  /* Added by marca. */
!       if (*auth_string == '\0') {
!           /*
!            *  Signal an abort. - FM
!            */
!           StrAllocCopy(HTAA_composeAuthResult, "");
!           return(HTAA_composeAuthResult);
        }
!       len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 
26;
!       if (!(HTAA_composeAuthResult = (char*)calloc(1, sizeof(char) * len)))
!           outofmem(__FILE__, "HTAA_composeAuth");
!       strcpy(HTAA_composeAuthResult, "Proxy-Authorization: ");
  
!     } else {  /* not proxy authorisation  -AJL */
  
!       if (TRACE)
!           fprintf(stderr, 
!                   "Composing Authorization for %s:%d/%s\n",
!                   hostname, portnumber, docname);
      
!       if (current_portnumber != portnumber ||
!           !current_hostname || !current_docname ||
!           !hostname         || !docname         ||
!           0 != strcmp(current_hostname, hostname) ||
!           0 != strcmp(current_docname, docname)) {
!     
!           retry = NO;
!     
!           current_portnumber = portnumber;
!           
!           if (hostname)
!               StrAllocCopy(current_hostname, hostname);
!           else
!               FREE(current_hostname);
!     
!           if (docname)
!               StrAllocCopy(current_docname, docname);
!           else
!               FREE(current_docname);
!       } else {
!           retry = YES;
!       }
!       
!       if (!current_setup || !retry)
!           current_setup = HTAASetup_lookup(hostname, portnumber, docname);
!     
!       if (!current_setup)
!           return NULL;
!         
!       switch (scheme = HTAA_selectScheme(current_setup)) {
!         case HTAA_BASIC:
!         case HTAA_PUBKEY:
!           auth_string = compose_auth_string(scheme, current_setup);
!           break;
!         case HTAA_KERBEROS_V4:
!           /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */
!         default:
!           {
!               char msg[100];
!               sprintf(msg, "%s %s `%s'",
!                       "This client doesn't know how to compose 
authentication",
!                       "information for scheme", HTAAScheme_name(scheme));
!               HTAlert(msg);
!               auth_string = NULL;
!           }
!       } /* switch scheme */
!     
!       current_setup->retry = NO;
!     
!       if (!auth_string)
!           /*
!            *  Signal a failure. - FM
!            */
!           return NULL;  /* Added by marca. */
!       if (*auth_string == '\0') {
!           /*
!            *  Signal an abort. - FM
!            */
!           StrAllocCopy(HTAA_composeAuthResult, "");
!           return(HTAA_composeAuthResult);
!       }
!       
!       len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 
20;
!       if (!(HTAA_composeAuthResult = (char*)calloc(1, sizeof(char) * len)))
!           outofmem(__FILE__, "HTAA_composeAuth");
!       strcpy(HTAA_composeAuthResult, "Authorization: ");
!     }
! 
      strcat(HTAA_composeAuthResult, HTAAScheme_name(scheme));
      strcat(HTAA_composeAuthResult, " ");
      strcat(HTAA_composeAuthResult, auth_string);
***************
*** 944,950 ****
            char *arg1 = HTNextField(&p);
            char *args = p;
            
!           if (0==strcasecomp(fieldname, "WWW-Authenticate:")) {
                if (!(arg1 && *arg1 && args && *args)) {
                    temp = (char *)calloc(1, strlen(line) +
                                             (arg1 ? strlen(arg1) : 0) +
--- 1033,1040 ----
            char *arg1 = HTNextField(&p);
            char *args = p;
            
!           if ((auth_proxy && 0==strcasecomp(fieldname, 
"Proxy-Authenticate:")) ||
!               (!auth_proxy && 0==strcasecomp(fieldname, 
"WWW-Authenticate:"))) {
                if (!(arg1 && *arg1 && args && *args)) {
                    temp = (char *)calloc(1, strlen(line) +
                                             (arg1 ? strlen(arg1) : 0) +
***************
*** 980,986 ****
                }
            }
  
!           else if (0==strcasecomp(fieldname, "WWW-Protection-Template:")) {
                if (TRACE)
                    fprintf(stderr, "Protection template set to `%s'\n", arg1);
                StrAllocCopy(template, arg1);
--- 1070,1076 ----
                }
            }
  
!           else if (!auth_proxy && 0==strcasecomp(fieldname, 
"WWW-Protection-Template:")) {
                if (TRACE)
                    fprintf(stderr, "Protection template set to `%s'\n", arg1);
                StrAllocCopy(template, arg1);
***************
*** 997,1051 ****
  
  
      /*
!     **  So should we retry with authorization
      */
-     if (num_schemes == 0) {           /* No authentication valid */
-       current_setup = NULL;
-       return NO;
-     }
  
!     if (current_setup && current_setup->server) {
!       /* So we have already tried with authorization. */
!       /* Either we don't have access or username or   */
!       /* password was misspelled.                     */
!           
!       /* Update scheme-specific parameters    */
!       /* (in case they have expired by chance).       */
!       HTAASetup_updateSpecifics(current_setup, scheme_specifics);
  
!       if (NO == HTConfirm("Authorization failed.  Retry?")) {
!           current_setup = NULL;
            return NO;
!       } /* HTConfirm(...) == NO */
!       else { /* re-ask username+password (if misspelled) */
!           current_setup->retry = YES;
            return YES;
!       } /* HTConfirm(...) == YES */
!     } /* if current_setup != NULL */
  
!     else { /* current_setup == NULL, i.e. we have a    */
!          /* first connection to a protected server or  */
!          /* the server serves a wider set of documents */
!          /* than we expected so far.                   */
  
!       HTAAServer *server = HTAAServer_lookup(current_hostname,
!                                              current_portnumber);
!       if (!server) {
!           server = HTAAServer_new(current_hostname,
!                                   current_portnumber);
        }
!       if (!template)
!           template = HTAA_makeProtectionTemplate(current_docname);
!       current_setup = HTAASetup_new(server, 
!                                     template,
!                                     valid_schemes,
!                                     scheme_specifics);
!       FREE(template);
  
!         HTAlert("Access without authorization denied -- retrying");
!       return YES;
!     } /* else current_setup == NULL */
! 
      /* Never reached */
  }
  
--- 1087,1194 ----
  
  
      /*
!     **  So should we retry with authorization?
      */
  
!     if (auth_proxy) { /* doing it for proxy  -AJL */
  
!       if (num_schemes == 0) {         /* No authentication valid */
!           proxy_setup = NULL;
            return NO;
!       }
!     
!       if (proxy_setup && proxy_setup->server) {
!           /* So we have already tried with authorization.     */
!           /* Either we don't have access or username or       */
!           /* password was misspelled.                 */
!               
!           /* Update scheme-specific parameters        */
!           /* (in case they have expired by chance).   */
!           HTAASetup_updateSpecifics(proxy_setup, scheme_specifics);
!     
!           if (NO == HTConfirm("Authorization failed.  Retry?")) {
!               proxy_setup = NULL;
!               return NO;
!           } /* HTConfirm(...) == NO */
!           else { /* re-ask username+password (if misspelled) */
!               proxy_setup->retry = YES;
!               return YES;
!           } /* HTConfirm(...) == YES */
!       } /* if proxy_setup != NULL */
!     
!       else { /* proxy_setup == NULL, i.e. we have a    */
!              /* first connection to a protected server or  */
!              /* the server serves a wider set of documents */
!              /* than we expected so far.                   */
!     
!           HTAAServer *server = HTAAServer_lookup(proxy_hostname,
!                                                  proxy_portnumber);
!           if (!server) {
!               server = HTAAServer_new(proxy_hostname,
!                                       proxy_portnumber);
!           }
!           if (!template)      /* Proxy matches everything  -AJL */
!               StrAllocCopy(template, "*");
!           proxy_setup = HTAASetup_new(server, 
!                                         template,
!                                         valid_schemes,
!                                         scheme_specifics);
!           FREE(template);
!     
!           HTAlert("Proxy authentication required -- retrying");
            return YES;
!       } /* else proxy_setup == NULL */
  
!     } else {  /* not proxy  -AJL */
  
!       if (num_schemes == 0) {         /* No authentication valid */
!           current_setup = NULL;
!           return NO;
        }
!     
!       if (current_setup && current_setup->server) {
!           /* So we have already tried with authorization.     */
!           /* Either we don't have access or username or       */
!           /* password was misspelled.                 */
!               
!           /* Update scheme-specific parameters        */
!           /* (in case they have expired by chance).   */
!           HTAASetup_updateSpecifics(current_setup, scheme_specifics);
!     
!           if (NO == HTConfirm("Authorization failed.  Retry?")) {
!               current_setup = NULL;
!               return NO;
!           } /* HTConfirm(...) == NO */
!           else { /* re-ask username+password (if misspelled) */
!               current_setup->retry = YES;
!               return YES;
!           } /* HTConfirm(...) == YES */
!       } /* if current_setup != NULL */
!     
!       else { /* current_setup == NULL, i.e. we have a  */
!              /* first connection to a protected server or  */
!              /* the server serves a wider set of documents */
!              /* than we expected so far.                   */
!     
!           HTAAServer *server = HTAAServer_lookup(current_hostname,
!                                                  current_portnumber);
!           if (!server) {
!               server = HTAAServer_new(current_hostname,
!                                       current_portnumber);
!           }
!           if (!template)
!               template = HTAA_makeProtectionTemplate(current_docname);
!           current_setup = HTAASetup_new(server, 
!                                         template,
!                                         valid_schemes,
!                                         scheme_specifics);
!           FREE(template);
!     
!           HTAlert("Access authentication required -- retrying");
!           return YES;
!       } /* else current_setup == NULL */
  
!     }
      /* Never reached */
  }
  
;
; 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]