Dirk> Note: Slide uses the HttpClient 1.x version, I didn't 
Dirk> check what the behaviour of version 2.x is.

PutMethod.setRequestBody(URL) (or PutMethod.setRequestBody(InputStream))
should also work in 2.x.  

Alternatively, in 2.x, one could extend HttpMethodBase, and override the
processResponseBody method to do as you describe:

Dmitry> change the behavior of the code, to, having parsed 
Dmitry> the headers, leave the content data inside the original
Dmitry> input stream, so that, if needed, this stream could 
Dmitry> be returned to the caller instead of a new one made 
Dmitry> from a locally cached copy?  A new method, let's say, 
Dmitry> getMethodDataUnprocessed() would simply return this stream,
Dmitry> while calling getMethodData() would make a call to 
Dmitry> parseResponse() first, and then continue with the 
Dmitry> old behavior.

This "lazy parsing" approach might even be appropriate in all cases,
although as you mention closing the stream my be a concern.

 - Rod

Reply via email to