Do POST request with Android DefaultHTTPClient cause freeze on execute()
<p>I need post data to server.
I use this code:</p>

<pre><code>HttpClient client = new DefaultHttpClient();
try {

    HttpPost httppost = new HttpPost(serverUrl);

    StringEntity se = new StringEntity(data);
    httppost.setEntity(se);
    httppost.setHeader("Accept", "application/json");
    httppost.setHeader("Content-type", "application/json");

    // Execute HTTP Post Request
    HttpResponse response = client.execute(httppost);
    int statusCode = response.getStatusLine().getStatusCode();
    Log.i(TVProgram.TAG, "ErrorHandler post status code: " + statusCode);

} catch (Exception e) {
    e.printStackTrace();
} finally {
    if (client != null) {
        client.getConnectionManager().shutdown();
    }
}
</code></pre>

<p>But problem is that Android freeze on execute() method, application is blocked out and after some time Android tell me that application doesn't respond.</p>

<p>I tried to debug into SDK classes and it freeze in AbstractSessionInputBuffer class on the line 103 which is </p>

<pre><code>l = this.instream.read(this.buffer, off, len);
</code></pre>

<p>I also tried it run the request in separated thread, but the same problem.</p>

<p>I tested it on Android 2.1 (emulator) and Android 2.2 real mobile device.<br>
I also tried to set HTTP proxy and use Fiddler to check HTTP communication data are received by server and server also send correct answer and HTTP code 200. All seems to be ok.</p>

<p>What is wrong please? </p>

<p>UPDATE: When I use AndroidHttpClient which is part of Android 2.2 SDK it works great. But it is not in earlier version of Android. So I include it's source code in my app for now. But AndroidHttpClient use DefaultHTTPClient internally, so problem will be in configuration of DefaultHttpClient.</p>
