2006/unicorn/src/org/w3c/unicorn/request Request.java,1.5,1.6

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/request
In directory hutz:/tmp/cvs-serv2429/src/org/w3c/unicorn/request

Modified Files:
	Request.java 
Log Message:
new streamToResponse() code (must be further tested)

Index: Request.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/request/Request.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Request.java	17 Sep 2009 16:37:19 -0000	1.5
+++ Request.java	18 Sep 2009 15:00:23 -0000	1.6
@@ -4,6 +4,7 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.unicorn.request;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -135,20 +136,29 @@
 	}
 
 	protected Response streamToResponse(InputStream is) throws Exception {
-		StringBuilder builder = new StringBuilder();
+		
+		InputStreamReader isr = new InputStreamReader(is, "UTF-8");
+		BufferedReader buf = new BufferedReader(isr);
+		StringBuilder build = new StringBuilder();
+		int c = buf.read();
+		while (c != -1) {
+			build.append((char) c);
+			c = buf.read();
+		} 
+		
+		/*StringBuilder builder = new StringBuilder();
 		InputStreamReader isr = new InputStreamReader(is, "UTF-8");
+		
 		char[] chararray = new char[8192];
 		int readLength = 0;
-		Response res;
-		
+	
 		while ((readLength = isr.read(chararray, 0, 8192)) > -1) {
 			builder.append(chararray, 0, readLength);
-		}
+		}*/
 		
-		res = ResponseParserFactory.parse(builder.toString(), this.getResponseType());
-		if(res != null) {
-			res.setXml(builder);
-		}
+		Response res = ResponseParserFactory.parse(build.toString(), this.getResponseType());
+		if(res != null)
+			res.setXml(build);
 
 		return res;
 	}

Received on Friday, 18 September 2009 15:00:35 UTC