title: HttpListener HTTP error 400
body: <p>I am using the <code>HttpListener</code> to implement a simple HTTP protocol for my connection service. When I connect with a browser to it, it works fine, but if I use Android's <code>DefaultHttpClient</code>, I get a "400 Bad Request".</p>
  
  <p>C# code:</p>
  
  <pre><code>httpListener = new HttpListener();
  httpListener.Prefixes.Add(String.Format("http://*:{0}/", port));
  httpListener.Start();
  </code></pre>
  
  <p>Java code:</p>
  
  <pre><code>HttpPost post = new HttpPost(path);
  HttpClient client = new DefaultHttpClient();
  HttpHost httphost = new HttpHost(host, port);
  
  StringEntity body = new StringEntity("Stuff I post", "UTF-8");
  body.setContentType("text/xml");
  post.setEntity(body);
  
  response = client.execute(httphost, post);
  StatusLine status = response.getStatusLine();
  </code></pre>
  
  <p>Nowhere can I find out what exactly goes wrong, all I get is "400 Bad Request". When I look at the POST by listening to a simple port, what I see looks OK.</p>
  
  <p>Frustrating thing is that it worked a few days ago.</p>