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 Re: HttpClient Help.
Date Thu, 22 Aug 2002 16:55:17 GMT
Hi and thanks for your response,

Is this the actual InputStream from the socket or the 
ByteArrayInputStream/FileInputStream I've been seeing in the sourcecode?

 From current copy of HttpMethodBase.java in CVS

/**
* Return my response body, if any,
* as an {@link InputStream}.
* Otherwise return <tt>null</tt>.
*/
public InputStream getResponseBodyAsStream() throws IOException {
return null == responseBody ? null :
new ByteArrayInputStream(responseBody);
}

this looks buffered to me. responseBody is a byte[]. The connection is 
loading the entire body ( - headers ) into a byte array. I want the 
InputStream prior to this data dumping process that is coming from the 
socket, this is not a very scalable approach because getting an 
InputStream isn't very valuable if its not coming straight from the socket.

I though maybe you might be referring to an overloaded version of this 
in GetMethod, but it just does something similar

/**
* Return my response body, if any,
* as an {@link InputStream}.
* Otherwise return <tt>null</tt>.
*
* @since 2.0
*/
public InputStream getResponseBodyAsStream()
throws IOException {
log.trace("enter GetMethod.getResponseBodyAsStream()");

checkUsed();
if (useDisk) {
return new FileInputStream(fileData);
} else {
if(null == memoryData) {
return null;
} else {
return new ByteArrayInputStream(memoryData);
}
}
}

So getResponseBodyAsStream does not appear to be what one might think in 
this case.

-Cheers,
Mark Diggory



Jeff Dever wrote:

>Hey Mark,
>
>HttpClient nightly builds have a way to get the response body as a stream.
>Any HttpMethod object has an appropriately named getResponseBodyAsStream()
>method that you can call after the HttpMethod has been successfully
>executed.
>
>You can then directly stream the data from the webserver directly to your
>application.
>
>
>-----Original Message-----
>From: Mark R. Diggory [mailto:mdiggory@latte.harvard.edu]
>Sent: Thursday, August 22, 2002 11:34 AM
>To: commons-dev@jakarta.apache.org
>Subject: HttpClient Help.
>
>
>Hi,
>
>I'm working with the HttpClient in my webapplication, unfortunately I'm
>"GET"ing some pretty large documents through the Http Client. Is there
>any way I can stop it from "buffering" the response and just hand me the
>"real" InputStream from the request? It's not very helpfull to store the
>entire response in memory or file when all you want is to hand it on to
>a SAX parser.
>
>-Mark Diggory
>Harvard-MIT Data Center
>
>
>
>--
>To unsubscribe, e-mail:
><mailto:commons-dev-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
><mailto:commons-dev-help@jakarta.apache.org>
>
>
>  
>



--
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