public InputStream get(String url) throws IOException {
HttpGet get = null;
boolean ok = false;
try {
// don't bother with challenges
DefaultHttpClient client = new PreemptiveAuth(m_cManager);
client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 20000);
client.getCredentialsProvider().setCredentials(m_authScope, m_creds);
int redirectCount = 0; // how many redirects did we follow
int resultCode = 300; // not really, but enter the loop that way
Dimension d = null;
HttpResponse response = null;
while (resultCode > 299 && resultCode < 400 && redirectCount < 25) {
get = new HttpGet(url);
client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);
if (Administrator.INSTANCE != null) {
d = Administrator.PROGRESS.getSize();
// if they're using Administrator, tell them we're downloading...
Administrator.PROGRESS.setString("Downloading " + url
+ " . . .");
Administrator.PROGRESS.setValue(100);
Administrator.PROGRESS.paintImmediately(0, 0, (int) d
.getWidth() - 1, (int) d.getHeight() - 1);
}
response = client.execute(get);
resultCode = response.getStatusLine().getStatusCode();
if (resultCode > 299 && resultCode < 400) {
redirectCount++;
url = response.getFirstHeader(HttpHeaders.LOCATION).getValue();
}