mturk       2002/10/09 10:08:10

  Modified:    jk/native2/common jk_uriMap.c
  Log:
  Fix the hostMap checking hostname:port then hostname
  
  Revision  Changes    Path
  1.51      +21 -14    jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c
  
  Index: jk_uriMap.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- jk_uriMap.c       3 Oct 2002 10:32:29 -0000       1.50
  +++ jk_uriMap.c       9 Oct 2002 17:08:09 -0000       1.51
  @@ -256,31 +256,40 @@
   {
       int i, j, n;
       char *name;
  -    char hostame[1024] = {0};
  +    char hostname[1024] = {0};
   
       if (port) {
           if (vhost) {
               if (strchr(vhost, ':'))
  -                strcpy(hostame, vhost);
  +                strcpy(hostname, vhost);
               else
  -               sprintf(hostame, "%s:%d", vhost, port);
  +               sprintf(hostname, "%s:%d", vhost, port);
           }
           else
  -            sprintf(hostame, "*:%d", port);
  +            sprintf(hostname, "*:%d", port);
       }
       else if (vhost)
  -        strcpy(hostame, vhost); 
  +        strcpy(hostname, vhost); 
       else /* Return default host if vhost and port wasn't suplied */
           return uriMap->vhosts->get(env, uriMap->vhosts, "*");
       
       n = uriMap->vhosts->size(env, uriMap->vhosts);
  -    /* Check the hostnames first */
  +    /* Check the exact hostname:port first */
       for (i = 0 ; i < n ; i++) {
           jk_uriEnv_t *uriEnv = uriMap->vhosts->valueAt(env, uriMap->vhosts, i);
           name = uriMap->vhosts->nameAt(env, uriMap->vhosts, i);
           /* Host name is not case sensitive */
  -        if (strcasecmp(name, hostame) == 0) {
  -            if (port == 0 || port == uriEnv->port)
  +        if (strcasecmp(name, hostname) == 0 && port == uriEnv->port)
  +            return uriEnv;
  +    }
  +
  +    if (vhost) {
  +        /* Check the hostname */
  +        for (i = 0 ; i < n ; i++) {
  +            jk_uriEnv_t *uriEnv = uriMap->vhosts->valueAt(env, uriMap->vhosts, i);
  +            name = uriMap->vhosts->nameAt(env, uriMap->vhosts, i);
  +            /* Host name is not case sensitive */
  +            if (strcasecmp(name, vhost) == 0)
                   return uriEnv;
           }
       }
  @@ -292,10 +301,8 @@
               int m = uriEnv->aliases->size(env, uriEnv->aliases);
               for (j = 0; j < m; j++) {
                   name = uriEnv->aliases->nameAt(env, uriEnv->aliases, j);
  -                if (strcasecmp(name, hostame) == 0) {
  -                    if (port == 0 || port == uriEnv->port)
  -                        return uriEnv;
  -                }
  +                if (strcasecmp(name, hostname) == 0)
  +                    return uriEnv;
               }
           }
       }
  @@ -574,7 +581,7 @@
       const char *str_minus_one=str-1;
       const char *s=str+strlen(str);
       while(s!=str_minus_one && ch!=*s) {
  -     --s;
  +    --s;
       }
       return (s-str);
   }
  @@ -632,7 +639,7 @@
       */
       
       if (uriMap == NULL || uri==NULL) 
  -         return NULL;
  +        return NULL;
       
       if (uriMap->mbean->debug > 1)
           env->l->jkLog(env, env->l, JK_LOG_DEBUG,
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to