title: org.apache.http.ProtocolException: Invalid header: <?xml version="1.0" encoding="UTF-8"?>
body: <p>Its been long I am stuck with this issue, from my androidApp HTTP get used to work fine with my Cable Modem HTTP server but at client place with <strong>linux</strong> <strong>mini_httpd</strong> I am getting this org.apache.http.client.ClientProtocolException soon after</p>
  
  <pre><code>httpClient.execute(httpget);
  </code></pre>
  
  <p>I did lot of research before posting this question here, before I was not setting contentType as xml but I am doing it     </p>
  
  <pre><code>httpget.setHeader("Content-Type", "application/xml"); but still struggling with same error.
  </code></pre>
  
  <p>Detailed code is as below</p>
  
  <pre><code>HttpParams httpParameters = new BasicHttpParams();
  int timeoutConnection = 10000;
  HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
  int timeoutSocket = 25000;
  HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
  
     HttpGet httpget = new HttpGet(URL);          
  
     httpget.setHeader("Content-Type", "application/xml");
     httpget.addHeader("Accept", "text/xml");
     httpget.setParams(httpParameters);
  
     HttpClient httpClient = new DefaultHttpClient();
     HttpResponse response = null;
     try {
         response = httpClient.execute(httpget);
         StatusLine statusLine = response.getStatusLine();
         if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
             Log.d("Http response", "response string got");
  
             /* parse the response received from server */
             try {
                 cmInfo = xmlParser.parse(response.getEntity().getContent());
                 Log.d("Http Response","back in main");
             } catch (XmlPullParserException e1) {
                 Log.d("parse:", "XmlPullParserException");
                 e1.printStackTrace();
             } catch (IOException e1) {
                 Log.d("parse:", "IOException");
                 e1.printStackTrace();
             }
      }
     } catch (ClientProtocolException e) {
          e.printStackTrace();
          Toast.makeText(getApplicationContext(), errMsg2, Toast.LENGTH_LONG).show();
      } catch (IOException e) {
          e.printStackTrace();
          Toast.makeText(getApplicationContext(), errMsg1, Toast.LENGTH_LONG).show();
      } catch (Exception e) {
          e.printStackTrace();
          Toast.makeText(getApplicationContext(), "Connection Refused from server or Connection Timeout", Toast.LENGTH_LONG).show();
      }
  </code></pre>
  
  <p>Kindly suggest what to be done or is there any workaround.</p>
  
  <p>And here is the logcat</p>
  
  <pre><code>03-18 18:41:08.246: D/getWifiDetails: cmURL:(32090): http://192.168.0.1:50010?
  03-18 18:41:08.246: D/WizardYourWifiActivity: URL-(32090): http://192.168.0.1:50010?get_data=PARM_WIFI_SSIDNAME_2_4G,PARM_WIFI_SSIDNAME_5G,PARM_WIFI_SECURITYMODE_2_4G,PARM_WIFI_SECURITYMODE_5G,PARM_WIFI_PASSPHRASE_2_4G,PARM_WIFI_PASSPHRASE_5G,PARM_WIFI_MODE_2_4G,PARM_WIFI_MODE_5G,PARM_WIFI_POWER_2_4G,PARM_WIFI_POWER_5G,PARM_WIFI_CHANNEL_2_4G,PARM_WIFI_CHANNEL_5G,PARM_WIFI_GUEST_NW_EN_2_4G,PARM_WIFI_GUEST_NW_EN_5G
  03-18 18:41:08.707: W/System.err(32090): org.apache.http.client.ClientProtocolException
  03-18 18:41:08.713: W/System.err(32090):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)
  03-18 18:41:08.713: W/System.err(32090):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
  03-18 18:41:08.713: W/System.err(32090):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
  03-18 18:41:08.713: W/System.err(32090):    at com.arrisi.selfinstall.wizard.WizardYourWifiActivity.doCustomCreate(WizardYourWifiActivity.java:98)
  03-18 18:41:08.713: W/System.err(32090):    at com.arrisi.selfinstall.wizard.BaseWizardActivity.onCreate(BaseWizardActivity.java:44)
  03-18 18:41:08.713: W/System.err(32090):    at android.app.Activity.performCreate(Activity.java:5933)
  03-18 18:41:08.713: W/System.err(32090):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
  03-18 18:41:08.713: W/System.err(32090):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
  03-18 18:41:08.713: W/System.err(32090):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
  03-18 18:41:08.713: W/System.err(32090):    at android.app.ActivityThread.access$800(ActivityThread.java:144)
  03-18 18:41:08.714: W/System.err(32090):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
  03-18 18:41:08.714: W/System.err(32090):    at android.os.Handler.dispatchMessage(Handler.java:102)
  03-18 18:41:08.714: W/System.err(32090):    at android.os.Looper.loop(Looper.java:135)
  03-18 18:41:08.714: W/System.err(32090):    at android.app.ActivityThread.main(ActivityThread.java:5221)
  03-18 18:41:08.714: W/System.err(32090):    at java.lang.reflect.Method.invoke(Native Method)
  03-18 18:41:08.714: W/System.err(32090):    at java.lang.reflect.Method.invoke(Method.java:372)
  03-18 18:41:08.714: W/System.err(32090):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
  03-18 18:41:08.714: W/System.err(32090):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  03-18 18:41:08.714: W/System.err(32090): Caused by: org.apache.http.ProtocolException: Invalid header: &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.impl.io.AbstractMessageParser.parseHeaders(AbstractMessageParser.java:162)
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:178)
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180)
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
  03-18 18:41:08.714: W/System.err(32090):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
  03-18 18:41:08.715: W/System.err(32090):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
  03-18 18:41:08.715: W/System.err(32090):    ... 17 more
  </code></pre>