mirror of
https://github.com/zxing/zxing.git
synced 2024-11-12 14:04:06 -08:00
Appear to have fixed the URL escaping issues this time without regression
git-svn-id: https://zxing.googlecode.com/svn/trunk@710 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
247e7c95bb
commit
ecc05c1ef3
|
@ -36,9 +36,6 @@ public final class QRCodeEncoder {
|
||||||
|
|
||||||
private static final String TAG = "QRCodeEncoder";
|
private static final String TAG = "QRCodeEncoder";
|
||||||
|
|
||||||
// Since this is an API call rather than a website, we don't use LocaleManager to change the TLD.
|
|
||||||
private static final String CHART_SERVER_URL = "//chart.apis.google.com/chart?cht=qr&chs=";
|
|
||||||
|
|
||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
private String mContents;
|
private String mContents;
|
||||||
private String mDisplayContents;
|
private String mDisplayContents;
|
||||||
|
@ -162,9 +159,8 @@ public final class QRCodeEncoder {
|
||||||
public final void run() {
|
public final void run() {
|
||||||
AndroidHttpClient client = null;
|
AndroidHttpClient client = null;
|
||||||
try {
|
try {
|
||||||
String url = CHART_SERVER_URL + mPixelResolution + "x" + mPixelResolution + "&chl=" +
|
URI uri = new URI("http", null, "chart.apis.google.com", -1, "/chart",
|
||||||
mContents;
|
"cht=qr&chs=" + mPixelResolution + "x" + mPixelResolution + "&chl=" + mContents, null);
|
||||||
URI uri = new URI("http", url, null);
|
|
||||||
HttpUriRequest get = new HttpGet(uri);
|
HttpUriRequest get = new HttpGet(uri);
|
||||||
client = AndroidHttpClient.newInstance(mUserAgent);
|
client = AndroidHttpClient.newInstance(mUserAgent);
|
||||||
HttpResponse response = client.execute(get);
|
HttpResponse response = client.execute(get);
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.json.JSONObject;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -53,12 +52,6 @@ public final class SearchBookContentsActivity extends Activity {
|
||||||
|
|
||||||
private static final String TAG = "SearchBookContents";
|
private static final String TAG = "SearchBookContents";
|
||||||
|
|
||||||
// These return a JSON result which describes if and where the query was found. This API may
|
|
||||||
// break or disappear at any time in the future. Since this is an API call rather than a website,
|
|
||||||
// we don't use LocaleManager to change the TLD.
|
|
||||||
private static final String BOOK_SEARCH_URL = "//www.google.com/books?vid=isbn";
|
|
||||||
private static final String BOOK_SEARCH_COMMAND = "&jscmd=SearchWithinVolume2&q=";
|
|
||||||
|
|
||||||
private NetworkThread mNetworkThread;
|
private NetworkThread mNetworkThread;
|
||||||
private String mISBN;
|
private String mISBN;
|
||||||
private EditText mQueryTextView;
|
private EditText mQueryTextView;
|
||||||
|
@ -243,10 +236,12 @@ public final class SearchBookContentsActivity extends Activity {
|
||||||
public final void run() {
|
public final void run() {
|
||||||
AndroidHttpClient client = null;
|
AndroidHttpClient client = null;
|
||||||
try {
|
try {
|
||||||
String url = BOOK_SEARCH_URL + mISBN + BOOK_SEARCH_COMMAND + URLEncoder.encode(mQuery, "UTF8");
|
// These return a JSON result which describes if and where the query was found. This API may
|
||||||
URI uri = new URI("http", url, null);
|
// break or disappear at any time in the future. Since this is an API call rather than a website,
|
||||||
|
// we don't use LocaleManager to change the TLD.
|
||||||
|
URI uri = new URI("http", null, "www.google.com", -1, "/books", "vid=isbn" + mISBN + "&jscmd=SearchWithinVolume2&q=" + mQuery, null);
|
||||||
HttpUriRequest get = new HttpGet(uri);
|
HttpUriRequest get = new HttpGet(uri);
|
||||||
get.setHeader("cookie", getCookie("http:" + url));
|
get.setHeader("cookie", getCookie(uri.toString()));
|
||||||
client = AndroidHttpClient.newInstance(mUserAgent);
|
client = AndroidHttpClient.newInstance(mUserAgent);
|
||||||
HttpResponse response = client.execute(get);
|
HttpResponse response = client.execute(get);
|
||||||
if (response.getStatusLine().getStatusCode() == 200) {
|
if (response.getStatusLine().getStatusCode() == 200) {
|
||||||
|
@ -261,8 +256,7 @@ public final class SearchBookContentsActivity extends Activity {
|
||||||
message.obj = json;
|
message.obj = json;
|
||||||
message.sendToTarget();
|
message.sendToTarget();
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "HTTP returned " + response.getStatusLine().getStatusCode() +
|
Log.e(TAG, "HTTP returned " + response.getStatusLine().getStatusCode() + " for " + uri);
|
||||||
" for http:" + url);
|
|
||||||
Message message = Message.obtain(mHandler, R.id.search_book_contents_failed);
|
Message message = Message.obtain(mHandler, R.id.search_book_contents_failed);
|
||||||
message.sendToTarget();
|
message.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue