title: curl post audio data with rate limit
body: <p>I am trying to post audio data with curl for a HTTP-API which allows to transmit/receive audio files.</p>
  
  <p>First I tried this: </p>
  
  <pre><code>curl -vv --http1.0 -H "Content-Type: audio/basic" -H "Content-Length: 9999999" -H "Connection: Keep-Alive" -H "Cache-Control: no-cache" --data-binary @- 'http://IP/API-Endpoint.cgi'
  </code></pre>
  
  <p>This seems to work:</p>
  
  <pre><code>*   Trying [IP]...
  * TCP_NODELAY set
  * Connected to [IP] ([IP]) port 80 (#0)
  &gt; POST /API-Endpoint.cgi HTTP/1.0
  &gt; Host: [IP]
  &gt; User-Agent: curl/7.54.0
  &gt; Accept: */*
  &gt; Content-Type: audio/basic
  &gt; Content-Length: 9999999
  &gt; Connection: Keep-Alive
  &gt; Cache-Control: no-cache
  &gt; 
  * upload completely sent off: 17456 out of 17456 bytes
  * HTTP 1.0, assume close after body
  &lt; HTTP/1.0 200 OK
  &lt; Content-Type: text/plain
  &lt; Content-Length: 0
  * HTTP/1.0 connection set to keep alive!
  &lt; Connection: keep-alive
  &lt; Date: Wed, 06 Jun 2018 19:38:37 GMT
  &lt; Server: lighttpd/1.4.45
  </code></pre>
  
  <p>But I can only hear the very last part of the Audio file. (The file has the correct audio format for the API: G.711 μ-law with 8000 Hz) My next guess is, that the audio gets transmitted too fast and has to be sent in real time to the API endpoint. So I tried the <code>--limit-rate</code> parameter of curl, which had no effect. Then I tried piping the data with a rate limit into curl:</p>
  
  <pre><code>cat myfile.wav | pv -L 10k | curl -vv --http1.0 -H "Content-Type: audio/basic" -H "Content-Length: 9999999" -H "Connection: Keep-Alive" -H "Cache-Control: no-cache" --data-binary @- 'http://IP/API-Endpoint.cgi'
  </code></pre>
  
  <p>but the result is always the same: I can only hear the last part of the audio file. It seems like curl is waiting for the piped input to complete and then sends the request as before.</p>
  
  <p>Is there an option to post audio to a HTTP-API from bash in "real time"?</p>
  
  <p><strong>Update:</strong>
  Without forcing HTTP 1.0 I get the following result:</p>
  
  <pre><code>curl -vv -H "Content-Type: audio/basic" --data-binary '@myfile.wav' 'http://[IP]/API-Endpoint.cgi'
  *   Trying [IP]...
  * TCP_NODELAY set
  * Connected to [IP] ([IP]) port 80 (#0)
  &gt; POST /API-Endpoint.cgi HTTP/1.1
  &gt; Host: [IP]
  &gt; User-Agent: curl/7.54.0
  &gt; Accept: */*
  &gt; Content-Type: audio/basic
  &gt; Content-Length: 15087
  &gt; Expect: 100-continue
  &gt; 
  &lt; HTTP/1.1 417 Expectation Failed
  &lt; Content-Type: text/html
  &lt; Content-Length: 363
  &lt; Connection: close
  &lt; Date: Wed, 06 Jun 2018 20:34:22 GMT
  &lt; Server: lighttpd/1.4.45
  &lt; 
  &lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
   &lt;head&gt;
    &lt;title&gt;417 - Expectation Failed&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;h1&gt;417 - Expectation Failed&lt;/h1&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  * Closing connection 0
  </code></pre>