You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Steve Johnson <sj...@mercury.com> on 2004/05/13 23:22:18 UTC
Where are the response bits being read over the wire?
Hi All,
We are extending classes in an initail effort to instrument DNS, connect, response(first buffer read), and
download.
The DNS and connect looks pretty good.
Where are the bits actually being retrieved over the wire?
Overriding HttpMethodBase. byte[] getResponseBody() and adding response and download times returns reasonable
looking response times, but almost all the download duration times are 0. Here is the current code. It is
derived from GetMethod.java
public byte[] getResponseBody() {
if (this.responseBody == null) {
try {
boolean firstReadDone = false;
InputStream instream = getResponseBodyAsStream();
if (instream != null) {
LOG.debug("Buffering response body");
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int len;
while ((len = instream.read(buffer)) > 0) {
outstream.write(buffer, 0, len);
if ( !firstReadDone ) {
responseEnd = System.currentTimeMillis();
}
System.out.println("ApacheGetMethod.getResponseBody() path: " + getPath() + " bytes
read: " + len );
firstReadDone = true;
}
outstream.close();
setResponseStream(null);
this.responseBody = outstream.toByteArray();
}
} catch (IOException e) {
LOG.error("I/O failure reading response body", e);
this.responseBody = null;
}
long downloadEnd = System.currentTimeMillis();
downloadDuration = downloadEnd - responseEnd;
System.out.println("ApacheGetMethod.getResponseBody() path: " + getPath() + " responseEnd: " +
responseEnd + " downloadEnd: " + downloadEnd + " downloadDuration: " + downloadDuration );
}
return this.responseBody;
}
Thanks for any ideas or information,
Steve
Steve Johnson
Software Engineer
Mercury Interactive
720 564 - 6532
USA, Canada and the Americas
720 564-6620
Hours: M-F 08:00-17:00 MST (Mountain Standard Time)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<http://www.mercuryinteractive.com> http://www.mercuryinteractive.com
Looking for Answers to your SiteScope or SiteSeer questions? <http://support.mercuryinteractive.com>
http://support.mercuryinteractive.com
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Re: Where are the response bits being read over the wire?
Posted by Michael Becke <be...@u.washington.edu>.
Hi Steve,
Could it be that most of the responses are less that 4KB? This would
explain the zero times since the timer does not start until after the
first read. If would suggest setting responseEnd before the while
loop. Also, it could be that System.currentTimeMillis() does not
provide enough resolution to measure the time accurately.
Mike
On May 13, 2004, at 5:22 PM, Steve Johnson wrote:
> Hi All,
>
> We are extending classes in an initail effort to instrument DNS,
> connect, response(first buffer read), and
> download.
> The DNS and connect looks pretty good.
>
> Where are the bits actually being retrieved over the wire?
> Overriding HttpMethodBase. byte[] getResponseBody() and adding
> response and download times returns reasonable
> looking response times, but almost all the download duration times are
> 0. Here is the current code. It is
> derived from GetMethod.java
>
> public byte[] getResponseBody() {
> if (this.responseBody == null) {
> try {
> boolean firstReadDone = false;
> InputStream instream = getResponseBodyAsStream();
> if (instream != null) {
> LOG.debug("Buffering response body");
> ByteArrayOutputStream outstream = new
> ByteArrayOutputStream();
> byte[] buffer = new byte[4096];
> int len;
> while ((len = instream.read(buffer)) > 0) {
> outstream.write(buffer, 0, len);
> if ( !firstReadDone ) {
> responseEnd = System.currentTimeMillis();
> }
>
> System.out.println("ApacheGetMethod.getResponseBody() path: " +
> getPath() + " bytes
> read: " + len );
> firstReadDone = true;
> }
> outstream.close();
> setResponseStream(null);
> this.responseBody = outstream.toByteArray();
> }
> } catch (IOException e) {
> LOG.error("I/O failure reading response body", e);
> this.responseBody = null;
> }
> long downloadEnd = System.currentTimeMillis();
> downloadDuration = downloadEnd - responseEnd;
> System.out.println("ApacheGetMethod.getResponseBody()
> path: " + getPath() + " responseEnd: " +
> responseEnd + " downloadEnd: " + downloadEnd + " downloadDuration: " +
> downloadDuration );
> }
> return this.responseBody;
> }
>
> Thanks for any ideas or information,
>
> Steve
>
> Steve Johnson
> Software Engineer
> Mercury Interactive
> 720 564 - 6532
> USA, Canada and the Americas
> 720 564-6620
> Hours: M-F 08:00-17:00 MST (Mountain Standard Time)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> <http://www.mercuryinteractive.com> http://www.mercuryinteractive.com
> Looking for Answers to your SiteScope or SiteSeer questions?
> <http://support.mercuryinteractive.com>
> http://support.mercuryinteractive.com
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org