title: client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23) - From Android
body: <p>I am seeing this in Apache Logs. Basically the request is going from Android Emulator using <code>HTTPUrlConnection</code>. Here is my code. </p>
  
  <pre><code>                URL url = new URL(strUrl);  
              Log.d(params[0],"UR");  
  
  
              conn = (HttpURLConnection) url.openConnection();
              conn.setRequestProperty("Authorization", "Basic " + Base64.encodeToString(toencode, Base64.DEFAULT));
              conn.setRequestProperty("Host", "www.domain.com");
              conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.3.1)");
              conn.setRequestProperty("Accept-Charset", "UTF-8");
              conn.setRequestMethod("GET");
  
              conn.setConnectTimeout (30000) ; 
              conn.setDoOutput(true); 
              conn.setDoInput(true); 
              conn.connect();
              String data = conn.getInputStream().toString();
              return data;
  </code></pre>
  
  <p>I am sending the user-agent header to make sure the server is not filtering non-recognizable user agents. I captured the traffic using Wireshark. The request seems to be okay. Not sure what else to look for. Spending hours on this without luck.</p>
  
  <pre><code> GET Authenticate/ HTTP/1.1\r\n
   Host: www.domain.com\r\n
   User-Agent: Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.3.1)\r\n
   Accept-Charset: UTF-8\r\n
   Connection: Keep-Alive\r\n
   Accept-Encoding: gzip\r\n
   \r\n
  </code></pre>
  
  <p>Response from Server:</p>
  
  <pre><code> Request Version: HTTP/1.1
   Status Code: 400
   Response Phrase: Bad Request
  
  
   &lt;h1&gt;Bad Request&lt;/h1&gt;\n
   &lt;p&gt;Your browser sent a request that this server could not understand.&lt;br /&gt;\n
  </code></pre>
  
  <p>and in the apache logs:</p>
  
  <pre><code> client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23)
  </code></pre>
  
  <p>At this point I feel like I need to go back to HttpClient and try it. I thought I should use <code>HttpUrlConnection</code> because google recommends it. But I am having no luck with <code>HttpURLConnection</code>.</p>
  
  <p>Anyone has any idea?</p>