xml-soap-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanj...@locus.apache.org
Subject cvs commit: xml-soap/java/src/org/apache/soap/server/http RPCRouterServlet.java
Date Thu, 10 Aug 2000 03:01:29 GMT
sanjiva     00/08/09 20:01:29

  Modified:    java/src/org/apache/soap/server/http RPCRouterServlet.java
  Log:
  added code to enable setting contentLength on the http response
  Submitted by:	Steven J. McDowall
  Reviewed by:	Sanjiva
  
  Revision  Changes    Path
  1.3       +19 -3     xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java
  
  Index: RPCRouterServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RPCRouterServlet.java	2000/08/10 02:40:36	1.2
  +++ RPCRouterServlet.java	2000/08/10 03:01:29	1.3
  @@ -130,11 +130,18 @@
       String contentType = req.getContentType ();
       int contentLength = req.getContentLength ();
   
  -    // set the outgoing content type and pick up the writer to write
  -    // to *after* that
  +    // set the outgoing content type
       res.setContentType (Constants.HEADERVAL_CONTENT_TYPE_UTF8);
  -    PrintWriter out = res.getWriter ();
       
  +    // Create a char writer buffer to hold the output
  +    // so we can get the length and set it..
  +    // Note: 4096 is just the initial size..it grows automatically..
  +    // We then create a "proper" OutputStreamWriter of the "standard"
  +    // encoding style that Java understands...
  +    ByteArrayOutputStream bytes = new ByteArrayOutputStream (4096) ;
  +    PrintWriter out = new PrintWriter (new OutputStreamWriter (bytes, "UTF8"),
  +				       true) ;
  +
       Call call = null;
       
       if ((contentType == null) ||
  @@ -338,5 +345,14 @@
   	throw new ServletException ("Error building response envelope", e);
         }
       }
  +
  +    // close the temporary writer to flush stuff out
  +    out.close ();
  +
  +    // Now set the return content length
  +    res.setContentLength (bytes.size ()) ;
  +    
  +    // Send the data out
  +    bytes.writeTo (res.getOutputStream ()) ;
     }
   }
  
  
  

Mime
View raw message