title: HttpRequest Entity(body) is empty when request is sent using Java HttpCore
body: <p>Already trying for number of hours to send general POST message to the server.
  I'm using HTTP Core library.</p>
  
  <p>All headers seems to be composed correctly, but somehow the body (Entity) of the message is being deleted and not sent to the server.
  The problem occurs after calling "process" command or the same "preProcess".
  Note: this is practically identical to official Apache example.
  Would be thankful for any advices.</p>
  
  <pre><code>import java.net.*;
  import org.apache.http.HttpHost;
  import org.apache.http.HttpRequestInterceptor;
  import org.apache.http.HttpResponse;
  import org.apache.http.HttpVersion;
  import org.apache.http.entity.StringEntity;
  import org.apache.http.impl.DefaultHttpClientConnection;
  import org.apache.http.message.BasicHttpEntityEnclosingRequest;
  import org.apache.http.params.HttpParams;
  import org.apache.http.params.HttpProtocolParams;
  import org.apache.http.params.SyncBasicHttpParams;
  import org.apache.http.protocol.HttpContext;
  import org.apache.http.protocol.BasicHttpContext;
  import org.apache.http.protocol.ExecutionContext;
  import org.apache.http.protocol.HttpProcessor;
  import org.apache.http.protocol.HttpRequestExecutor;
  import org.apache.http.protocol.ImmutableHttpProcessor;
  import org.apache.http.protocol.RequestConnControl;
  import org.apache.http.protocol.RequestContent;
  import org.apache.http.protocol.RequestExpectContinue;
  import org.apache.http.protocol.RequestTargetHost;
  import org.apache.http.protocol.RequestUserAgent;
  import org.apache.http.util.EntityUtils;
  
  public class HTTPCommunicator
  {
      public static String TOKEN = null;
  
      public static void main(String[] args) throws Exception
      {           
          BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/api");
  
          HttpHost host = new HttpHost("localhost", 80);
  
          HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
          HttpContext context = new BasicHttpContext(null);
          DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
          context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
          context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, host);
  
          request.addHeader("Host", "localhost");
          request.addHeader("Accept", "application/json,application/xml");
          request.addHeader("Accept-Encoding", "gzip, deflate");
  
          HttpParams params = new SyncBasicHttpParams();
          HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
          HttpProtocolParams.setContentCharset(params, "UTF-8");
          HttpProtocolParams.setUserAgent(params, "MyClient");
          HttpProtocolParams.setUseExpectContinue(params, true);
  
          request.setParams(params);      
  
          String sRequest = "userName=yourusername&amp;password=yourpassword";
          request.setEntity(new StringEntity(sRequest));
  
          HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
                  // Required protocol interceptors
          new RequestContent(), new RequestTargetHost(),
                  // Recommended protocol interceptors
          new RequestConnControl(), new RequestUserAgent(), new RequestExpectContinue() });
  
          httpproc.process(request, context);
  
          //httpexecutor.preProcess(request, httpproc, context);
  
          //Sending request
          Socket socket = new Socket(host.getHostName(), host.getPort());
          conn.bind(socket, params);
          HttpResponse response = httpexecutor.execute(request, conn, context);
  
          System.out.println(EntityUtils.toString(response.getEntity()));
      }
  </code></pre>