Improve verbose debugging

This commit is contained in:
Cameron Gutman 2015-02-25 19:55:16 -05:00
parent 814557435d
commit 6eaabc84aa

View File

@ -256,7 +256,20 @@ public class NvHTTP {
} }
String openHttpConnectionToString(String url, boolean enableReadTimeout) throws MalformedURLException, IOException { String openHttpConnectionToString(String url, boolean enableReadTimeout) throws MalformedURLException, IOException {
ResponseBody resp = openHttpConnection(url, enableReadTimeout); if (verbose) {
LimeLog.info("Requesting URL: "+url);
}
ResponseBody resp;
try {
resp = openHttpConnection(url, enableReadTimeout);
} catch (IOException e) {
if (verbose) {
e.printStackTrace();
}
throw e;
}
Scanner s = new Scanner(resp.byteStream()); Scanner s = new Scanner(resp.byteStream());
String str = ""; String str = "";
@ -268,7 +281,7 @@ public class NvHTTP {
resp.close(); resp.close();
if (verbose) { if (verbose) {
System.out.println(str); LimeLog.info(url+" -> "+str);
} }
return str; return str;
@ -364,11 +377,17 @@ public class NvHTTP {
} }
public LinkedList<NvApp> getAppList() throws GfeHttpResponseException, IOException, XmlPullParserException { public LinkedList<NvApp> getAppList() throws GfeHttpResponseException, IOException, XmlPullParserException {
if (verbose) {
// Use the raw function so the app list is printed
return getAppListByReader(new StringReader(getAppListRaw()));
}
else {
ResponseBody resp = openHttpConnection(baseUrl + "/applist?uniqueid=" + uniqueId, true); ResponseBody resp = openHttpConnection(baseUrl + "/applist?uniqueid=" + uniqueId, true);
LinkedList<NvApp> appList = getAppListByReader(new InputStreamReader(resp.byteStream())); LinkedList<NvApp> appList = getAppListByReader(new InputStreamReader(resp.byteStream()));
resp.close(); resp.close();
return appList; return appList;
} }
}
public void unpair() throws IOException { public void unpair() throws IOException {
openHttpConnectionToString(baseUrl + "/unpair?uniqueid=" + uniqueId, true); openHttpConnectionToString(baseUrl + "/unpair?uniqueid=" + uniqueId, true);