title: Meaning of "The server returned an invalid or unrecognized response" in HttpClient
body: <p>When awaiting an <code><a href="https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient" rel="noreferrer">HttpClient</a>.PostAsync</code> response, I sometimes see an error stating <em>"The server returned an invalid or unrecognized response"</em>:</p>
  
  <pre><code>System.Net.Http.HttpRequestException: An error occurred while sending the request. ---&gt; System.Net.Http.WinHttpException: The server returned an invalid or unrecognized response
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
     at System.Net.Http.WinHttpHandler.&lt;StartRequest&gt;d__105.MoveNext()
     --- End of inner exception stack trace ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
     at System.Net.Http.HttpClient.&lt;FinishSendAsync&gt;d__58.MoveNext()
  </code></pre>
  
  <p>That's a pretty cryptic error; I suppose I can conceive of what an "invalid" response might possibly be (i.e. a syntactically-invalid HTTP response, like one that jumps straight into headers without a status line), but what on earth is an "unrecognized" response to a HTTP request? The message seems like nonsense.</p>
  
  <p>What circumstances can actually trigger this error, under the hood?</p>