title: Reading boost::asio::streambuf yields bad data
body: <p>I'm using boost::asio to create a TCP client.  I'm testing it out by loading a web site.  I can create a connection, read, have my callback fired, etc, no problem.  However, at the of every packet, I'm finding this, or something like it:</p>
  
  <pre><code>ýýýý««««««««îþîþ
  </code></pre>
  
  <p>I'm wondering how I can determine the size of what was actually read.  In the code below, assume my socket is set up properly.  I've connected to a URL (a plain old web site), sent a request, and have started reading.  When I read the data, I get the data back, plus some extra weirdness.</p>
  
  <pre><code>class TcpClient
  {
      ...
  
      boost::asio::streambuf mResponse;
      std::shared_ptr&lt;boost::asio::ip::tcp::socket&gt; mSocket;
  
      ...
  
      void read()
      {
          boost::asio::async_read( *mSocket, mResponse, 
              boost::asio::transfer_at_least( 1 ), 
              boost::bind( &amp;TcpClient::onRead, shared_from_this(), 
                  boost::asio::placeholders::error, 
                  boost::asio::placeholders::bytes_transferred ) );
      }
  
      void onRead( const boost::system::error_code&amp; err, size_t bytesTransferred )
      {
          if ( err ) {
              if ( err == boost::asio::error::eof ) {
                  cout &lt;&lt; "Read complete" &lt;&lt; endl;
              } else {
                  cout &lt;&lt; "Error" &lt;&lt; endl;
              }
          } else {
              char* data = new char[ bytesTransferred ];
              istream stream( &amp;mResponse );
              stream.read( data, bytesTransferred );
  
              cout  &lt;&lt; data &lt;&lt; endl;
  
              delete [] data;
              read();
          }
          mResponse.consume( mResponse.size() );
      }
  
      ...
  
  };
  </code></pre>
  
  <p>Below is the result of the first packet I receive from <a href="http://libcinder.org" rel="nofollow">http://libcinder.org</a>.</p>
  
  <pre><code>HTTP/1.1 200 OK
  Server: nginx/0.5.33
  Date: Fri, 24 May 2013 01:05:55 GMT
  Content-Type: text/html; charset=utf-8
  Connection: close
  Vary: Cookie
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
      &lt;title&gt;Cinder | The library for professional-quality creative coding in C++&lt;/title&gt;
  
      &lt;meta name="Descýýýý««««««««îþîþ
  </code></pre>