2006/unicorn/org/w3c/unicorn/request DirectRequestPOST.java,1.6,1.7 DirectRequestGET.java,1.4,1.5 Request.java,1.6,1.7

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

Modified Files:
	DirectRequestPOST.java DirectRequestGET.java Request.java 
Log Message:


Index: DirectRequestPOST.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/request/DirectRequestPOST.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- DirectRequestPOST.java	17 Jun 2008 14:09:50 -0000	1.6
+++ DirectRequestPOST.java	27 Aug 2008 12:09:45 -0000	1.7
@@ -4,8 +4,12 @@
 // 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;
 import java.io.OutputStream;
+import java.io.StringBufferInputStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Hashtable;
@@ -169,8 +173,23 @@
 		this.aOutputStream.write("--".getBytes());
 		this.aOutputStream.write("\r\n".getBytes());
 		this.aOutputStream.close();
-		return ResponseParserFactory.parse(aURLConnection.getInputStream(),
+		
+		InputStream is = aURLConnection.getInputStream();
+		StringBuffer sb = new StringBuffer();
+		
+		BufferedReader br = new BufferedReader(new InputStreamReader(is));
+		String s;
+		while ((s = br.readLine()) != null) {
+			sb.append(s + "\n");
+		}
+		br.close();
+		this.setResponseBuffer(sb);
+		
+		StringBufferInputStream sbis = new StringBufferInputStream(sb.toString());
+		Response aObservationResponse = ResponseParserFactory.parse(sbis,
 				this.getResponseType());
+		aObservationResponse.setXml(sb);
+		return aObservationResponse;
 	}
 
 	@Override

Index: DirectRequestGET.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/request/DirectRequestGET.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- DirectRequestGET.java	17 Jun 2008 13:41:11 -0000	1.4
+++ DirectRequestGET.java	27 Aug 2008 12:09:45 -0000	1.5
@@ -4,7 +4,11 @@
 // 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;
+import java.io.StringBufferInputStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
@@ -98,8 +102,22 @@
 		}
 		final URLConnection aURLConnection = aURL.openConnection();
 		aURLConnection.setRequestProperty("Accept-Language", this.sLang);
-		return ResponseParserFactory.parse(aURLConnection.getInputStream(),
+		InputStream is = aURLConnection.getInputStream();
+		StringBuffer sb = new StringBuffer();
+		
+		BufferedReader br = new BufferedReader(new InputStreamReader(is));
+		String s;
+		while ((s = br.readLine()) != null) {
+			sb.append(s + "\n");
+		}
+		br.close();
+		this.setResponseBuffer(sb);
+		
+		StringBufferInputStream sbis = new StringBufferInputStream(sb.toString());
+		Response aObservationResponse = ResponseParserFactory.parse(sbis,
 				this.getResponseType());
+		aObservationResponse.setXml(sb);
+		return aObservationResponse;
 	}
 
 	@Override

Index: Request.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/request/Request.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Request.java	2 Jul 2008 17:34:47 -0000	1.6
+++ Request.java	27 Aug 2008 12:09:45 -0000	1.7
@@ -5,6 +5,7 @@
 package org.w3c.unicorn.request;
 
 import java.io.IOException;
+import java.io.InputStream;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -22,6 +23,10 @@
 	protected static final Log logger = LogFactory
 			.getLog("org.w3c.unicorn.request");
 
+	protected InputStream responseStream;
+	protected StringBuffer responseBuffer;
+	
+	
 	/**
 	 * Language of the request
 	 */
@@ -85,7 +90,7 @@
 	 *            type of the response
 	 * @return a request ready to be done
 	 * @throws IOException
-	 *             odd error occurend
+	 *             odd error occurred
 	 */
 	public static Request createRequest(final InputModule aInputModule,
 			final String sURL, final String sInputParameterName,
@@ -130,5 +135,21 @@
 	public void setResponseType(String responseType) {
 		this.responseType = responseType;
 	}
+	
+	public InputStream getResponseStream() {
+		return responseStream;
+	}
+	
+	public void setResponseStream(InputStream is) {
+		this.responseStream = is;
+	}
+	
+	public StringBuffer getResponseBuffer() {
+		return responseBuffer;
+	}
+	
+	public void setResponseBuffer(StringBuffer sb) {
+		this.responseBuffer = sb;
+	}
 
 }

Received on Wednesday, 27 August 2008 12:10:22 UTC