HttpClient.PostAsync Unrecognized Response
<p>If I run my web application on a Windows machine everything works out fine. When I run this application on a Linux (CentOS) machine I get the following exception when trying so send the Post request:</p>

<blockquote>
  <p>System.Net.Http.HttpRequestException: The server returned an invalid or unrecognized response. at System.Net.Http.CurlResponseHeaderReader.ReadHeader(String&amp; headerName, String&amp; headerValue) at System.Net.Http.CurlHandler.MultiAgent.CurlReceiveHeadersCallback(IntPtr buffer, UInt64 size, UInt64 nitems, IntPtr context) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
</blockquote>

<p>This is the code that makes the post call:</p>

<pre><code>    Uri uri = new Uri(ServiceConfiguration.SERVICE_URL);

    string sSOAPResponse = String.Empty;

    HttpClient hc = new HttpClient();

    hc.DefaultRequestHeaders.Add("SOAPAction", oRequest.Action);

    var content = new StringContent(oRequest.RequestMessage, Encoding.UTF8, "text/xml");

    try
    {
        using (HttpResponseMessage response = await hc.PostAsync(uri, content))
        {

            sSOAPResponse = await response.Content.ReadAsStringAsync();
            (...)
         }
</code></pre>

<p>I'm guessing that this is happening because of my headers definition. I've also tried using curl on the linux console to make a request and I got the response as expected. Am I doing something wrong with the header definitions?</p>

<p>CURL command example used with sucess (<a href="http://dasunhegoda.com/make-soap-request-command-line-curl/596/" rel="nofollow">Source</a>)</p>

<blockquote>
  <p>curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction: ACTION_YOU_WANT_TO_CALL" --data @FILE_NAME URL_OF_THE_SOAP_WEB_SERVICE_ENDPOINT</p>
</blockquote>

<p>SOAP UI Request (RAW):</p>

<blockquote>
  <p>POST <a href="http://xxx/xxx/xxx.php" rel="nofollow">http://xxx/xxx/xxx.php</a> HTTP/1.1 Accept-Encoding: gzip,deflate
  Content-Type: text/xml;charset=UTF-8 SOAPAction:
  "<a href="http://xxx/xxx/xxx.php/userLogin" rel="nofollow">http://xxx/xxx/xxx.php/userLogin</a>" Content-Length: 488 Host: xxx
  Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5</p>
</blockquote>