commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Possible Http Client Problem
Date Tue, 10 Sep 2002 17:59:07 GMT
I've been playing witht he CVS Checkout of the Http Client and I'm 
getting a wierd exception which I've included below. This code worked 
with the previous version of the Http Client I was using:

java.lang.Error
	at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:417)
	at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:442)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:179)
	at java.io.InputStreamReader.read(InputStreamReader.java:167)
	at org.apache.xerces.readers.CharReader.fillCurrentChunk(CharReader.java)
	at org.apache.xerces.readers.AbstractCharReader.slowLoadNextChar(AbstractCharReader.java)
	at org.apache.xerces.readers.AbstractCharReader.scanQName(AbstractCharReader.java)
	at org.apache.xerces.framework.XMLDocumentScanner.scanElementType(XMLDocumentScanner.java)
	at org.apache.xerces.framework.XMLDocumentScanner.access$1(XMLDocumentScanner.java)
	at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java)
	at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java)
	at org.apache.xerces.framework.XMLParser.parse(XMLParser.java)
	at com.icl.saxon.om.Builder.build(Builder.java:258)
	at com.icl.saxon.Controller.transform(Controller.java:925)


I'm using the InputStream from method.getContentAsStream() in a JAXP transform like this:

/* SNIP */

URL url = new URL("http://vdc.fas.harvard.edu/VDC/Repository/0.1/Access?name=http://purl.thedata.org/VDC/0.1/PURL/1.1.2/06635");

HttpConnection connection = new HttpConnection(url.getHost(),80);
GetMethod method = new GetMethod(url.getPath());
method.setQueryString(url.getQuery());

int state = method.execute(new HttpState(), connection);

if(state != 200){
    out.println("<p>State = "+ state+" Reason = " + method.getStatusText()+"</p>");
}else{
     TransformerFactory tfactory  = TransformerFactory.newInstance();
     Templates templates = tfactory.newTemplates(new StreamSource("MainView.xsl"));
     Transformer transformer = templates.newTransformer();
     transformer.transform(new StreamSource(method.getResponseBodyAsStream()),new StreamResult(out));
   
}

/* SNIP */

if I use the following test, I do get the content from the response:

InputStream in = method.getResponseBodyAsStream();

    int c;
    while((c = in.read()) != -1){
        out.write(c);
      }


Any Ideas?
Mark





--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message