mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 1016686p2 - Prevent HttpGet hangs during re-directed LoadFaviconTasks, r=rnewman, f=ckitching
This commit is contained in:
parent
c29f56c018
commit
fe3e07d96a
@ -140,25 +140,42 @@ public class LoadFaviconTask extends UiAsyncTask<Void, Void, Bitmap> {
|
||||
Header header = response.getFirstHeader("Location");
|
||||
|
||||
// Handle mad webservers.
|
||||
if (header == null) {
|
||||
return null;
|
||||
final String newURI;
|
||||
try {
|
||||
if (header == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
newURI = header.getValue();
|
||||
if (newURI == null || newURI.equals(faviconURI.toString())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (visited.contains(newURI)) {
|
||||
// Already been redirected here - abort.
|
||||
return null;
|
||||
}
|
||||
|
||||
visited.add(newURI);
|
||||
} finally {
|
||||
// Consume the entity before recurse or exit.
|
||||
try {
|
||||
response.getEntity().consumeContent();
|
||||
} catch (Exception e) {
|
||||
// Doesn't matter.
|
||||
}
|
||||
}
|
||||
|
||||
String newURI = header.getValue();
|
||||
if (newURI == null || newURI.equals(faviconURI.toString())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (visited.contains(newURI)) {
|
||||
// Already been redirected here - abort.
|
||||
return null;
|
||||
}
|
||||
|
||||
visited.add(newURI);
|
||||
return tryDownloadRecurse(new URI(newURI), visited);
|
||||
}
|
||||
|
||||
if (status >= 400) {
|
||||
// Consume the entity and exit.
|
||||
try {
|
||||
response.getEntity().consumeContent();
|
||||
} catch (Exception e) {
|
||||
// Doesn't matter.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user