Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: IllegalStateException in HttpGet
    primarykey
    data
    text
    <p>I'm trying to send a <code>GET</code> request using <code>HttpClient</code>, but I keep getting an <code>IllegalStateException</code>. Any idea what's causing this? I've been looking around for a solution, but I don't get what it means by <code>"host=null"</code> in the log. How do I set the host, and how is it different from the path? Here's my logcat out:</p> <pre><code>07-17 11:54:18.002: W/System.err(15422): java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=google.com 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.AbstractHttpClient$1.executeRequestSending(AbstractHttpClient.java:609) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.naf.redirect.NafRequestExecutorWrapperRedirectionHandler.executeRequestSendingUsual(NafRequestExecutorWrapperRedirectionHandler.java:96) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.naf.redirect.NafRequestExecutorWrapperRedirectionHandler.executeRequestSending(NafRequestExecutorWrapperRedirectionHandler.java:73) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.sendFirstRequest(NafHttpAuthStrategyDefault.java:487) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.performAuthExecutionUnsafe(NafHttpAuthStrategyDefault.java:388) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.performAuthExecution(NafHttpAuthStrategyDefault.java:200) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:558) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:508) 07-17 11:54:18.002: W/System.err(15422): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:486) 07-17 11:54:18.002: W/System.err(15422): at myapp.httprequest.free.GETActivity$1sendRequestTask.doInBackground(GETActivity.java:102) 07-17 11:54:18.002: W/System.err(15422): at myapp.httprequest.free.GETActivity$1sendRequestTask.doInBackground(GETActivity.java:1) 07-17 11:54:18.002: W/System.err(15422): at android.os.AsyncTask$2.call(AsyncTask.java:264) 07-17 11:54:18.002: W/System.err(15422): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 07-17 11:54:18.002: W/System.err(15422): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 07-17 11:54:18.002: W/System.err(15422): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 07-17 11:54:18.002: W/System.err(15422): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 07-17 11:54:18.002: W/System.err(15422): at java.lang.Thread.run(Thread.java:856) </code></pre> <p>and the source:</p> <pre><code>HttpClient getClient = new DefaultHttpClient(); HttpGet getData = new HttpGet(this.address); try { HttpResponse gameResponse = getClient.execute(getData); return EntityUtils.toString(gameResponse.getEntity()); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload