axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/transport/http HTTPDispatchHandler.java
Date Sat, 05 May 2001 11:44:32 GMT
dug         01/05/05 04:44:32

  Modified:    java/src/org/apache/axis Message.java
               java/src/org/apache/axis/transport/http
                        HTTPDispatchHandler.java
  Log:
  With Debug turned on we didn't get back any xml because "available"
  should not be used to get the full length of the data - it returns
  just wants available at that moment - and at the moment it was returning
  zero.  We need to loop until we hit EOF. This will only work on
  input streams that close their connection when done (ie. not on the
  incoming side of the server socket) but we're assuming he have content-
  length for those cases.  This looks like it's only a bug when debug
  is turned on because I believe when its not the input stream is passed
  directly to the xml parser who doesn't have this problem.
  
  Revision  Changes    Path
  1.27      +9 -2      xml-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Message.java	2001/05/02 23:43:38	1.26
  +++ Message.java	2001/05/05 11:44:32	1.27
  @@ -157,8 +157,15 @@
         // Assumes we don't need a content length
         try {
           InputStream  inp = (InputStream) currentMessage ;
  -        byte[]  buf = new byte[ inp.available() ];
  -        inp.read( buf );
  +        ByteArrayOutputStream  baos = new ByteArrayOutputStream();
  +        byte[]  buf = new byte[4096];
  +        int len ;
  +        while ( (len = inp.read(buf,0,4096)) != -1 )
  +          baos.write( buf, 0, len );
  +        buf = baos.toByteArray();
  +        // int len = inp.available();
  +        // byte[]  buf = new byte[ len ];
  +        // inp.read( buf );
           setCurrentMessage( buf, "Bytes" );
           Debug.Print( 2, "Exit: Message::getAsByes" );
           return( (byte[]) currentMessage );
  
  
  
  1.23      +21 -11    xml-axis/java/src/org/apache/axis/transport/http/HTTPDispatchHandler.java
  
  Index: HTTPDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPDispatchHandler.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- HTTPDispatchHandler.java	2001/05/04 19:20:14	1.22
  +++ HTTPDispatchHandler.java	2001/05/05 11:44:32	1.23
  @@ -94,6 +94,7 @@
         int      rc     = 0 ;
   
         host = tmpURL.getHost();
  +      Debug.Print(0, "HOST: " + host );
         if ( (port = tmpURL.getPort()) == -1 ) port = 80;
   
         Socket             sock = null ;
  @@ -273,17 +274,26 @@
         if ( b != -1 ) {
           if (Debug.getDebugLevel() > 0) {
             String contentLength = (String) headers.get("content-length");
  -          contentLength = contentLength.trim();
  -          byte[] data = new byte[Integer.parseInt(contentLength)];
  -          for (len=0; len<data.length; )
  -            len+= inp.read(data,len,data.length-len);
  -          String xml = new String(data);
  -
  -          outMsg = new Message( data, "Bytes" );
  -
  -          Debug.Print( 1, "\nXML received:" );
  -          Debug.Print( 1, "-------------------------------------------------");
  -          Debug.Print( 1, xml );
  +          if ( contentLength != null ) {
  +            contentLength = contentLength.trim();
  +            byte[] data = new byte[Integer.parseInt(contentLength)];
  +            for (len=0; len<data.length; )
  +              len+= inp.read(data,len,data.length-len);
  +            String xml = new String(data);
  +  
  +            outMsg = new Message( data, "Bytes" );
  +  
  +            Debug.Print( 1, "\nXML received:" );
  +            Debug.Print( 1, "-----------------------------------------------");
  +            Debug.Print( 1, xml );
  +          }
  +          else {
  +            outMsg = new Message( inp, "InputStream" );
  +            Debug.Print( 1, "\nNo Content-Length" );
  +            Debug.Print( 1, "\nXML received:" );
  +            Debug.Print( 1, "-----------------------------------------------");
  +            Debug.Print( 1, (String) outMsg.getAs("String") );
  +          }
           } else {
             outMsg = new Message( inp, "InputStream" );
           }
  
  
  

Mime
View raw message