title: cURL not sending content-length
body: <p>I'm trying to get an O-Auth token from the Spotify API but when using cURL on Debian 8 I always get the error message <code>POST requests require a Content-length header.</code> while it works on my MacBook.</p>
  <pre><code>$authString = $spotifyId . &quot;:&quot; . $spotifySecret;
  $encodedAuthString = base64_encode($authString);
  
  $spotifyHeaders = array(
      &quot;Authorization: Basic &quot; . $encodedAuthString,
      &quot;Content-Type: application/x-www-form-urlencoded&quot;,
  );
  
  $spotifyOauthCurl = curl_init();
  curl_setopt($spotifyOauthCurl, CURLOPT_URL, &quot;https://accounts.spotify.com/api/token&quot;);
  curl_setopt($spotifyOauthCurl, CURLOPT_POST, true);
  curl_setopt($spotifyOauthCurl, CURLOPT_HTTPHEADER, $spotifyHeaders);
  curl_setopt($spotifyOauthCurl, POSTFIELDS, &quot;grant_type=client_credentials&quot;);
  curl_setopt($spotifyOauthCurl, CURLOPT_RETURNTRANSFER, true);
  // curl_setopt($spotifyOauthCurl, CURLINFO_HEADER_OUT, true);
  $result = curl_exec($spotifyOauthCurl);
  echo curl_getinfo($spotifyOauthCurl, CURLINFO_HEADER_OUT);
  </code></pre>
  <p>Adding CURLOPT_VERBOSE as suggested by @hanshenrik returned the following output</p>
  <pre><code>Trying 35.186.224.25...
  * TCP_NODELAY set
  * Connected to accounts.spotify.com (35.186.224.25) port 443 (#0)
  * ALPN, offering http/1.1
  * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  * successfully set certificate verify locations:
  *   CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: /etc/ssl/certs
  * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
  * ALPN, server accepted to use http/1.1
  * Server certificate:
  *  subject: C=SE; L=Stockholm; O=Spotify AB; CN=*.spotify.com
  *  start date: May  3 00:00:00 2021 GMT
  *  expire date: May  3 23:59:59 2022 GMT
  *  subjectAltName: host &quot;accounts.spotify.com&quot; matched certs &quot;*.spotify.com&quot;
  *  issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS RSA SHA256 2020 CA1
  *  SSL certificate verify ok.
  &gt; POST /api/token HTTP/1.1
  
  /api/token?grant_type=client_credentials HTTP/1.1
  Host: accounts.spotify.com
  Accept: */ *
  Authorization: Basic ...
  Content-Type: application/x-www-form-urlencoded
  Expect: 100-continue
  
  * HTTP 1.0, assume close after body
  &lt; HTTP/1.0 411 Length Required
  &lt; Content-Type: text/html; charset=UTF-8
  &lt; Referrer-Policy: no-referrer
  &lt; Content-Length: 1564
  &lt; Date: Wed, 26 Jan 2022 17:36:23 GMT
  &lt; 
  * Curl_http_done: called premature == 0
  * Closing connection 0
  </code></pre>