Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001509 [Resin] major always 12-13-06 15:19 01-02-07 11:34
Reporter justinwcs View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 3.0.22
Summary 0001509: getServerPort() returns incorrect number
Description
Found a bug in getServerPort(). If you have a host like "localhost:8091" getServerPort() will say your host is 61419 because of this code in the com.caucho.server.connection.AbstractHttpRequest getServerPort() method. This is in 3.0.22.

      int length = host.length();
      int port = 0;

      for (int i = p1 + 1; i < length; i++) {
    char ch = host.charAt(i);

    if ('0' <= ch && ch <= '9')
      port = 10 * port + ch;
      }



  /**
   * Returns the server's port.
   */
  public int getServerPort()
  {
    String host = _conn.getVirtualHost();
    
    CharSequence rawHost;
    if (host == null && (rawHost = getHost()) != null) {
      int length = rawHost.length();
      int i;

      for (i = length - 1; i >= 0; i--) {
    if (rawHost.charAt(i) == ':') {
      int port = 0;

      for (i++; i < length; i++) {
        char ch = rawHost.charAt(i);

        if ('0' <= ch && ch <= '9')
          port = 10 * port + ch - '0';
      }

      return port;
    }
      }
      
      return isSecure() ? 443 : 80;
    }

    if (host == null)
      return _conn.getLocalPort();

    int p1 = host.lastIndexOf(':');
    if (p1 < 0)
      return isSecure() ? 443 : 80;
    else {
      int length = host.length();
      int port = 0;

      for (int i = p1 + 1; i < length; i++) {
    char ch = host.charAt(i);

    if ('0' <= ch && ch <= '9')
      port = 10 * port + ch;
      }

      return port;
    }
  }
Additional Information This bug prevents both the Cactus and Acegi security from doing redirects properly.
Attached Files

- Relationships

- Notes
(0001689)
ferg
01-02-07 11:34

server/052z
 

- Issue History
Date Modified Username Field Change
12-13-06 15:19 justinwcs New Issue
01-02-07 11:34 ferg Note Added: 0001689
01-02-07 11:34 ferg Assigned To  => ferg
01-02-07 11:34 ferg Status new => closed
01-02-07 11:34 ferg Resolution open => fixed
01-02-07 11:34 ferg Fixed in Version  => 3.0.23
01-02-07 11:34 ferg Description Updated


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
30 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker