PriyaranjanMohapatra / rest-client

Automatically exported from code.google.com/p/rest-client
Apache License 2.0
0 stars 0 forks source link

Should we handle automatic redirects? #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
http://hc.apache.org/httpclient-3.x/redirects.html

But this should be configurable in the Options panel.

Also, automatic retries should be communicated to the user in the status bar.

Original issue reported on code.google.com by subwiz on 27 Mar 2008 at 1:01

GoogleCodeExporter commented 8 years ago
View should have these additional methods:

doRetry()
doRedirect(URL)

Original comment by subwiz on 2 Apr 2008 at 11:08

GoogleCodeExporter commented 8 years ago
The ever helpful Oleg of HTTP Client mailed this in response to the query 
(asked by 
someone else, not me) in the HTTP Client mailing list:

** To get final request location:
--------
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("https://localhost/");

HttpContext context = new BasicHttpContext();
HttpResponse response = httpClient.execute(httpget, context);
HttpEntity entity = response.getEntity();
if (entity != null) {
   entity.consumeContent();
}
HttpUriRequest request = (HttpUriRequest) context.getAttribute(
       ExecutionContext.HTTP_REQUEST);

System.out.println(request.getURI());
--------

** To get all intermediate redirect locations:
--------
DefaultHttpClient httpClient = new DefaultHttpClient();

httpClient.setRedirectHandler(new DefaultRedirectHandler() {

   @Override
   public URI getLocationURI(HttpResponse response, HttpContext
context) throws ProtocolException {
       URI uri = super.getLocationURI(response, context);
       System.out.println("redirect - > " + uri);
       return uri;
   }

});

HttpGet httpget = new HttpGet("https://localhost/");
HttpResponse response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
   entity.consumeContent();
}
--------

Original comment by subwiz on 11 Nov 2008 at 5:55

GoogleCodeExporter commented 8 years ago
FYI, that code for determining the final request location is actually incorrect 
now, 
with the latest HttpClient. Here's the new way to do it:

RequestWrapper requestWrapper = (RequestWrapper) context.getAttribute
(ExecutionContext.HTTP_REQUEST);
HttpUriRequest request = (HttpUriRequest)requestWrapper.getOriginal();
String finalUrl = request.getURI().toString();

Original comment by matthewl...@gmail.com on 16 Apr 2009 at 8:00

GoogleCodeExporter commented 8 years ago
Thanks for letting me know! I will do a set of tests and fix it.

Original comment by subwiz on 17 Apr 2009 at 1:15

GoogleCodeExporter commented 8 years ago
[Issue: 94] Reported similar problem.

Original comment by subwiz on 15 Oct 2009 at 4:49