axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils tcpmon.java
Date Mon, 18 Mar 2002 22:06:28 GMT
tomj        02/03/18 14:06:28

  Modified:    java/src/org/apache/axis/utils tcpmon.java
  Log:
  Update tcpmon to change the Host: header in the request
  so it reflects the target host.
  
  Revision  Changes    Path
  1.28      +43 -3     xml-axis/java/src/org/apache/axis/utils/tcpmon.java
  
  Index: tcpmon.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/tcpmon.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- tcpmon.java	5 Mar 2002 10:00:51 -0000	1.27
  +++ tcpmon.java	18 Mar 2002 22:06:28 -0000	1.28
  @@ -464,7 +464,7 @@
                               if( done ) return;
                           }
                       }
  -                    // System.out.println("XXX Read result: " + this + " "  +len1 + " "
+ out);
  +                    //System.out.println("XXX Read result: " + this + " "  +len1 + " "
+ out);
                       len=len1;
                       if ( len == -1 ) break ;
   
  @@ -678,9 +678,9 @@
   
                   int index = listener.connections.indexOf( this );
   
  +                //
  +                // Check if we're a proxy
                   if ( listener.isProxyBox.isSelected() || HTTPProxyHost != null ) {
  -                    // Check if we're a proxy
  -                    int          ch ;
                       byte[]       b = new byte[1];
                       buf = new StringBuffer();
                       String       s ;
  @@ -736,6 +736,46 @@
                           }
   
                       }
  +                } else {
  +                    //
  +                    // Change Host: header to point to correct host
  +                    //
  +                    byte[] b1 = new byte[1];
  +                    buf = new StringBuffer();
  +                    String s1;
  +                    
  +                    for ( ;; ) {
  +                        int len ;
  +                        len = tmpIn1.read(b1, 0, 1);
  +                        if ( len == -1 ) 
  +                                break ;
  +                        s1 = new String( b1 );
  +                        buf.append( s1 );
  +                        if ( b1[0] != '\n' ) 
  +                                continue ;
  +                        // we have a complete line
  +                        String line = buf.toString();
  +                        buf.setLength(0);
  +                        // check to see if we have found Host: header
  +                        if (line.startsWith("Host: ")) {
  +                            // we need to update the hostname to be the target host
  +                            String newHost = "Host: " + targetHost + "\r\n";
  +                            bufferedData = bufferedData.concat(newHost);
  +                            break ;
  +                        } 
  +                        // add it to our headers so far
  +                        if (bufferedData == null)
  +                            bufferedData = line;
  +                        else
  +                            bufferedData = bufferedData.concat(line);
  +                    
  +                        // failsafe
  +                        if (line.equals("\r\n"))
  +                            break;
  +                    }
  +
  +                    if (bufferedData != null)
  +                        inputText.append( bufferedData );
                   }
   
                   if ( targetPort == -1 ) targetPort = 80 ;
  
  
  

Mime
View raw message