hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: ConnectionShutdownException when trying to get metrics after HEAD request
Date Sat, 09 Apr 2011 23:32:22 GMT
On 9 April 2011 13:20, sebb <sebbaz@gmail.com> wrote:
> The following code works fine for GET:
>
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
>
> but fails on the getMetrics() call when the request is HEAD:
>
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
>
> Is that intentional? Surely the metrics should still be valid?
>

As a work-round, I added an HttpResponseInterceptor that saves the
metrics object in the local context, and the metric now works with
HEAD and GET, which suggests it is still valid after connection
shutdown.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message