mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Avoid exception when someone scans a file:/// URL barcode. And don't process it.
git-svn-id: https://zxing.googlecode.com/svn/trunk@2420 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
6c306ad1c7
commit
6a94fe7225
|
@ -90,7 +90,11 @@ public final class HttpHelper {
|
|||
private static CharSequence downloadViaHttp(String uri, String contentTypes, int maxChars) throws IOException {
|
||||
Log.i(TAG, "Downloading " + uri);
|
||||
URL url = new URL(uri);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
URLConnection conn = url.openConnection();
|
||||
if (!(conn instanceof HttpURLConnection)) {
|
||||
throw new IOException();
|
||||
}
|
||||
HttpURLConnection connection = (HttpURLConnection) conn;
|
||||
connection.setRequestProperty("Accept", contentTypes);
|
||||
connection.setRequestProperty("Accept-Charset", "utf-8,*");
|
||||
connection.setRequestProperty("User-Agent", "ZXing (Android)");
|
||||
|
@ -151,7 +155,11 @@ public final class HttpHelper {
|
|||
}
|
||||
URL url = uri.toURL();
|
||||
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
URLConnection conn = url.openConnection();
|
||||
if (!(conn instanceof HttpURLConnection)) {
|
||||
throw new IOException();
|
||||
}
|
||||
HttpURLConnection connection = (HttpURLConnection) conn;
|
||||
connection.setInstanceFollowRedirects(false);
|
||||
connection.setDoInput(false);
|
||||
connection.setRequestMethod("HEAD");
|
||||
|
|
Loading…
Reference in a new issue