- From: Jonathan Barouh via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 27 Aug 2008 12:10:01 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/request
In directory hutz:/tmp/cvs-serv27570/org/w3c/unicorn/request
Modified Files:
UploadRequest.java URIRequest.java
Log Message:
Index: UploadRequest.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/request/UploadRequest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- UploadRequest.java 17 Jun 2008 13:41:11 -0000 1.5
+++ UploadRequest.java 27 Aug 2008 12:09:59 -0000 1.6
@@ -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.MalformedURLException;
import java.util.Hashtable;
import java.util.Map;
@@ -118,8 +122,23 @@
this.aClientHttpRequest.setParameter(sName, sValue);
}
final Response aObservationResponse;
- aObservationResponse = ResponseParserFactory.parse(
- this.aClientHttpRequest.post(), this.getResponseType());
+ InputStream is = this.aClientHttpRequest.post();
+
+ 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());
+
+ aObservationResponse = ResponseParserFactory.parse(sbis
+ , this.getResponseType());
+ aObservationResponse.setXml(sb);
return aObservationResponse;
}
Index: URIRequest.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/request/URIRequest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- URIRequest.java 17 Jun 2008 13:41:11 -0000 1.5
+++ URIRequest.java 27 Aug 2008 12:09:59 -0000 1.6
@@ -4,8 +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.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
@@ -48,7 +51,7 @@
* @throws IOException
* odd error occured
*/
- protected URIRequest(final String sURL, final String sInputParameterName,
+ public URIRequest(final String sURL, final String sInputParameterName,
final InputModule aInputModule, final String responseType)
throws IOException {
super();
@@ -116,9 +119,33 @@
final URLConnection aURLConnection = aURL.openConnection();
aURLConnection.setRequestProperty("Accept-Language", this.sLang);
+
InputStream is = aURLConnection.getInputStream();
- // Response res = this.aResponseParser.parse(is);
- Response res = ResponseParserFactory.parse(is, this.getResponseType());
+ //System.out.println("mark supported : " + is.markSupported());
+ //System.out.println("is class : " + is.getClass());
+ setResponseStream(is);
+
+ StringBuffer sb = new StringBuffer();
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String s;
+ while ((s = br.readLine()) != null) {
+ sb.append(s + "\n");
+ //System.out.println(s);
+ }
+ br.close();
+ this.setResponseBuffer(sb);
+
+
+ StringBufferInputStream sbis = new StringBufferInputStream(sb.toString());
+ //System.out.println(sb.toString());
+ //System.out.println("response stream set");
+ //Response res = this.aResponseParser.parse(is);
+ Response res = ResponseParserFactory.parse(sbis, this.getResponseType());
+ res.setXml(sb);
+ //Response res = null;
+ //System.out.println("response created");
+ //is.reset();
return res;
}
Received on Wednesday, 27 August 2008 12:10:34 UTC