Re: [xSocket-develop] Proxy example - piping data to file
Status: Inactive
Brought to you by:
grro
|
From: <gre...@we...> - 2008-04-10 11:18:53
|
Hi Martin, the xSocket Junit test BodyForwardingTest (http://xsocket.svn.sourceforge.net/viewvc/xsocket/xsocket/http/tags/V2_0_alpha4/src/test/java/org/xsocket/connection/http/BodyForwardingTest.java) contains a ForwardHandler which shows you how to control the message/body streaming. One fast way to fetch the complete message header is to call the toString method ... HttpResponseHeader resHdr = response.getResponseHeader(); String hdrCopy = resHdr.toString(); FileChannel fileChannel = new .... fileChannel.write(...) ... The body data can be fetched by duplicating the body ByteBuffer : ... ByteBuffer[] data = bodyDataSource.readByteBufferByLength(available); for (ByteBuffer buf : data) { fileChannel.write(buf.duplicate()); } dataSink.write(data); ... Take care with the NonThreaded annotations of the example code. If you are writing to a file, the handler should run in a multithreaded mode. The Nonthreaded annotation should be removed. Gregor > -----Ursprüngliche Nachricht----- > Von: "Martin Thelian" <Mar...@gm...> > Gesendet: 10.04.08 09:56:16 > An: xso...@li... > Betreff: [xSocket-develop] Proxy example - piping data to file > > Hi, > > I would like to use xsocket as described in [1] chapter "3.2 Reusing message objects - a proxy example" and additionally I would like to pipe the response-message into a file while transfering it back to the client. > > What is the best way to do this? > > Thanks, > Martin > > [1] http://xsocket.sourceforge.net/http/tutorial/V2/TutorialHttp.htm > -- > Psssst! Schon vom neuen GMX MultiMessenger gehört? > Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > xSocket-develop mailing list > xSo...@li... > https://lists.sourceforge.net/lists/listinfo/xsocket-develop |