My goal is to get the location after a get request with authentication
public class desZip {
public static void main(String[] args) {
try {
System.out.println("Imprimiendo Response Header...\n");
HttpClient client = new DefaultHttpClient();
HttpParams params = client.getParams();
HttpClientParams.setRedirecting(params, false);
HttpGet method = new HttpGet("http://url.com");
HttpResponse resp = client.execute(method);
BasicCookieStore cookieStore = new BasicCookieStore();
int i;
BasicClientCookie cookie = new BasicClientCookie("name", "UTF-8");
cookie.setValue("f1gfgogljmjvoplmufg5b8ai02");
String location = resp.getLastHeader("Location").getValue();
if (location == null) {
System.out.println("Key 'location' no encontrada!");
} else {
System.out.println("location - " + location);
}
System.out.println("\n Hecho");
} catch (Exception e) {
e.printStackTrace();
}
}
}