title: HTTP continuous packeted stream with Indy
body: <p>I have a JSON-RPC service which for one of the requests returns a continuous stream of JSON objects.</p>
  
  <p>I.e. :</p>
  
  <pre><code>{id:'1'}
  {id:'2'}
  //30 minutes of no data
  {id:'3'}
  //...
  </code></pre>
  
  <p>Of course, there's no Content-Length because the stream is endless.</p>
  
  <p>I'm using custom TStream descendant to receive and parse the data. But internally <code>TIdHttp</code> buffers the data and does not pass it to me until <code>RecvBufferSize</code> bytes are received.</p>
  
  <p>This results in:</p>
  
  <pre><code>{id:'1'} //received
  {id:'2'} //buffered by Indy but not received
  //30 minutes of no data
  {id:'3'} //this is where Indy commits {id:'2'} to me
  </code></pre>
  
  <p>Obviously this won't do because the message which mattered 30 minutes ago should have been delivered 30 minutes ago.</p>
  
  <p>I'd like Indy to do just what sockets do: read up to RecvBufferSize or less if there's data available and return immediately.</p>
  
  <p>I've found <a href="http://borland.newsgroups.archived.at/public.delphi.internet.winsock/200504/0504201980.html" rel="noreferrer">this discussion</a> from 2005 where some poor soul tried to explain the problem to Indy developers but they didn't understand him. (Read it; it's a sad sight)</p>
  
  <p>Anyway, he worked around this by writing custom IOHandler descendant, but that was back in 2005, maybe there are some ready solutions today?</p>