title: curl - empty headers in response
body: <p>I try curl on a host that it is a cash register printer. The printer can accept instructions via http in the body of the request, like this example:</p>
  
  <pre><code>[www@localhost ~]$ curl --trace curl.trace.log -d '
  &gt; clear
  &gt; vend rep=1, pre=10
  &gt; vend rep=2, pre=20
  &gt; chius
  &gt; wecfine
  &gt;' http://192.168.6.184:1471
  </code></pre>
  
  <p>But I can't understand why launching this command the destination host responds correctly to the instructions in the body and the printer work correctly but after the log response the connection is kept open for 30 seconds and after this time curl responds in this way: <code>Connection #0 to host 192.168.6.184 left intact</code>. My problem is that I tried to log response headers in all the ways (<code>--trace curl.trace.log</code>, <code>--trace-ascii curl.trace-ascii.log</code>, <code>--dump-header curl.dump-header.log</code> and the last <code>-v</code>) but none of these works. The only response log that I have with all the ways is this:</p>
  
  <pre><code>* About to connect() to 192.168.6.184 port 1471 (#0)
  *   Trying 192.168.6.184...
  * Connected to 192.168.6.184 (192.168.6.184) port 1471 (#0)
  &gt; POST / HTTP/1.1
  &gt; User-Agent: curl/7.29.0
  &gt; Host: 192.168.6.184:1471
  &gt; Accept: */*
  &gt; Content-Length: 57
  &gt; Content-Type: application/x-www-form-urlencoded
  &gt;
  * upload completely sent off: 57 out of 57 bytes
  OK.
  OK.
  OK.
  OK.
  OK.
  * Connection #0 to host 192.168.6.184 left intact
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p><strong>Why don't I get headers in the response despite using the verbose?</strong> I need to understand how the printer work and with headers I can get more information becouse I have to develop calls from a web application to this device.</p>
  
  <p><strong>Other information</strong></p>
  
  <p><em>For curl calls to the printer I will use php.</em></p>
  
  <p><em>This cash register has a really poor and incomplete documentation.</em></p>
  
  <p><strong>[Edit]</strong></p>
  
  <p>The curl command in PHP that is for test, the result is the same, the variable <code>$headers</code> is just an empty array!</p>
  
  <pre><code>$ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, 'http://192.168.6.184:1471');
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, '
  clear
  vend rep=1, pre=10
  vend rep=2, pre=20
  chius
  wecfine
  ');
  curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: text/plain']);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  $headers = [];
  curl_setopt($ch, CURLOPT_HEADERFUNCTION,
  function($curl, $header) use (&amp;$headers)
  {
      $len = strlen($header);
      $header = explode(':', $header, 2);
      if (count($header) &lt; 2) // ignore invalid headers
          return $len;
  
      $headers[strtolower(trim($header[0]))][] = trim($header[1]);
  
      return $len;
      }
  );
  
  $output=curl_exec($ch);
  curl_close($ch);
  </code></pre>