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:
srowen 2008-11-16 10:20:20 +00:00
parent 247e7c95bb
commit ecc05c1ef3
2 changed files with 8 additions and 18 deletions

View file

@ -36,9 +36,6 @@ public final class 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 String mContents;
private String mDisplayContents;
@ -162,9 +159,8 @@ public final class QRCodeEncoder {
public final void run() {
AndroidHttpClient client = null;
try {
String url = CHART_SERVER_URL + mPixelResolution + "x" + mPixelResolution + "&chl=" +
mContents;
URI uri = new URI("http", url, null);
URI uri = new URI("http", null, "chart.apis.google.com", -1, "/chart",
"cht=qr&chs=" + mPixelResolution + "x" + mPixelResolution + "&chl=" + mContents, null);
HttpUriRequest get = new HttpGet(uri);
client = AndroidHttpClient.newInstance(mUserAgent);
HttpResponse response = client.execute(get);

View file

@ -45,7 +45,6 @@ import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
@ -53,12 +52,6 @@ public final class SearchBookContentsActivity extends Activity {
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 String mISBN;
private EditText mQueryTextView;
@ -243,10 +236,12 @@ public final class SearchBookContentsActivity extends Activity {
public final void run() {
AndroidHttpClient client = null;
try {
String url = BOOK_SEARCH_URL + mISBN + BOOK_SEARCH_COMMAND + URLEncoder.encode(mQuery, "UTF8");
URI uri = new URI("http", url, null);
// 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.
URI uri = new URI("http", null, "www.google.com", -1, "/books", "vid=isbn" + mISBN + "&jscmd=SearchWithinVolume2&q=" + mQuery, null);
HttpUriRequest get = new HttpGet(uri);
get.setHeader("cookie", getCookie("http:" + url));
get.setHeader("cookie", getCookie(uri.toString()));
client = AndroidHttpClient.newInstance(mUserAgent);
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
@ -261,8 +256,7 @@ public final class SearchBookContentsActivity extends Activity {
message.obj = json;
message.sendToTarget();
} else {
Log.e(TAG, "HTTP returned " + response.getStatusLine().getStatusCode() +
" for http:" + url);
Log.e(TAG, "HTTP returned " + response.getStatusLine().getStatusCode() + " for " + uri);
Message message = Message.obtain(mHandler, R.id.search_book_contents_failed);
message.sendToTarget();
}