hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Getting URL from within a HttpRequestRetryHandler
Date Fri, 13 Aug 2010 08:05:35 GMT
On Thu, 2010-08-12 at 07:51 -0700, hbfkf wrote:
> Hi everybody,
> 
> I am trying to get the URL from within a HttpRequestRetryHandler in
> HttpClient 4. Is there a supported way to achieve this?
> 

I assume by URL you mean the request URI

---
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setHttpRequestRetryHandler(new
DefaultHttpRequestRetryHandler() {

    @Override
    public boolean retryRequest(
            IOException exception, int executionCount, HttpContext
context) {
        HttpRequest request = (HttpRequest)
context.getAttribute(ExecutionContext.HTTP_REQUEST);
        System.out.println(request.getRequestLine().getUri());
        HttpHost target = (HttpHost)
context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        System.out.println(target);
        return super.retryRequest(exception, executionCount, context);
    }

});
---

Oleg



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


Mime
View raw message