- From: Stephane Nicoll <stephane.nicoll@skynet.be>
- Date: Tue, 22 Jan 2002 19:20:52 +0100
- To: "Christopher William Turner" <cwturner@cycom.co.uk>
- Cc: <www-jigsaw@w3.org>
> > 2) "You say, recreate a new Inputstream that is a copy of the original
and
> > give to the rest of the filter stack". You mean, make a clone of this
> > inputstream and set it to the reply after having copied the file. Ok,
but
> > how can I clone it.
It does not work. Here is my code:
public Reply outgoingFilter(Request request, Reply reply)
throws HttpException
{
if ((reply.getStatus() < 400) && (reply.getStatus() != 301)
&& (reply.getStatus() != 307))
{
byte[] content = getFileContent(request, reply);
// make a clone of this content to set it in the reply
byte[] clone = new byte[content.length];
System.arraycopy(content,0,clone,0,content.length);
reply.setStream(new ByteArrayInputStream(clone));
// ok it's done ... Send the event to the listenr
}
return reply;
}
private static byte[] getFileContent(Request request, Reply reply)
{
byte [] buf1 = new byte [1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int inlen;
try {
InputStream stream = reply.getInputStream();
while(( inlen = stream.read(buf1,0,buf1.length)) > 0){
baos.write(buf1,0,inlen);
}
} catch(IOException ioe){
Logger.trace("I/O Proxy Error while retrieving the content of: "
+request.getURL().toString());
}
return baos.toByteArray();
}
I don't know which method of the reply I should call to set the stream to
higher stacks. When I run, i got no pages and I have the following error:
loading properties from: G:\e-learning\proxy\Jigsaw\config\server.props
Restoring state...
Restored cached state in 611 ms.
eConf ProxyFitler is now ready ...
Jigsaw[2.0.5]: serving at http://bettyboop:8001/
*** Warning : JigAdmin[2.0.5]: no logger specified, not logging.
JigAdmin[2.0.5]: serving at http://bettyboop:8009/
GET / HTTP/1.0
Proxy-Connection: Keep-Alive
Date: Tue, 22 Jan 2002 18:20:24 GMT
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-
powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: fr-be
Host: www.mail.be
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
+++ client-1(http-server-socket-clients:41) got exception:
org.w3c.www.http.HttpParserException: End Of File
at
org.w3c.www.http.HttpRequestMessage.notifyBeginParsing(HttpRequestMes
sage.java:175)
at org.w3c.www.mime.MimeParser.parse(MimeParser.java:186)
at org.w3c.www.mime.MimeParser.parse(MimeParser.java:212)
Please help!
Stéphane
Received on Tuesday, 22 January 2002 13:21:18 UTC