Index: trunk/BNC/bncsocket.cpp
===================================================================
--- trunk/BNC/bncsocket.cpp	(revision 1359)
+++ trunk/BNC/bncsocket.cpp	(revision 1360)
@@ -33,4 +33,5 @@
   _socket = 0;
   _http   = 0;
+  _buffer = 0;
 }
 
@@ -41,4 +42,5 @@
   delete _socket;
   delete _http;
+  delete _buffer;
 }
 
@@ -85,5 +87,12 @@
 ////////////////////////////////////////////////////////////////////////////
 qint64 bncSocket::bytesAvailable() const {
-  if (_socket) {
+  if      (_http) { 
+    for (int ii = 1; ii < 10; ii++) {
+      cout << "bytesAvailable " << _http->bytesAvailable() << endl;
+      msleep(100);
+    }
+    return _http->bytesAvailable();
+  }
+  else if (_socket) {
     return _socket->bytesAvailable();
   }
@@ -96,5 +105,8 @@
 ////////////////////////////////////////////////////////////////////////////
 bool bncSocket::canReadLine() const {
-  if (_socket) {
+  if      (_buffer) {
+    return _buffer->canReadLine();
+  }
+  else if (_socket) {
     return _socket->canReadLine();
   }
@@ -107,5 +119,8 @@
 ////////////////////////////////////////////////////////////////////////////
 QByteArray bncSocket::readLine(qint64 maxlen) {
-  if (_socket) {
+  if      (_buffer) {
+    return _buffer->readLine(maxlen);
+  }
+  else if (_socket) {
     return _socket->readLine(maxlen);
   }
@@ -118,5 +133,8 @@
 ////////////////////////////////////////////////////////////////////////////
 bool bncSocket::waitForReadyRead(int msecs) {
-  if (_socket) {
+  if      (_http) {
+    msleep(10);
+  }
+  else if (_socket) {
     return _socket->waitForReadyRead(msecs);
   }
@@ -301,8 +319,6 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-void bncSocket::slotReadyRead(const QHttpResponseHeader&) {
-  cout << "slotReadyRead" << endl;
-  QByteArray buffer = _http->readAll();
-  cout << buffer.data();
+void bncSocket::slotReadyRead() {
+  cout << "slotReadyRead " << _buffer->size() << endl;
 }
 
@@ -329,12 +345,7 @@
                          int timeOut, QString& msg) {
 
-  delete _socket;
-  _socket = new QTcpSocket();
-
   delete _http;
   _http = new QHttp();
   
-  _http->setSocket(_socket);
-
   _http->setHost(url.host());
 
@@ -359,11 +370,34 @@
   connect(_http, SIGNAL(requestFinished(int, bool)), 
           this, SLOT(slotRequestFinished(int, bool)));
-  connect(_http, SIGNAL(readyRead(const QHttpResponseHeader&)), 
-          this, SLOT(slotReadyRead(const QHttpResponseHeader&)));
   connect(_http, SIGNAL(sslErrors(const QList<QSslError>&)), 
           this, SLOT(slotSslErrors(const QList<QSslError>&)));
 
-  _http->request(request);
+  _buffer = new QBuffer();
+  _buffer->open(QBuffer::ReadWrite);
+  connect(_buffer, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
+
+  _http->request(request, 0, _buffer);
 
   return success;
 }
+
+// void startQuery(...)
+// {
+// 	m_eventLoop = new QEventLoop(this);
+// 	connect(this, SIGNAL(singleQueryDone()), m_eventLoop, SLOT(quit()));
+// 	connect( qHttp, SIGNAL( requestFinished(int,bool) ), this,
+// 		SLOT( dataDone(int, bool) ) );
+// 	qHttp->request( header, QByteArray(), m_buffer );
+// }
+// 
+// void dataDone( int, bool )
+// {
+// 	emit singleQueryDone();
+// }
+// 
+// void blockingThing()
+// {
+//         startQuery( );
+//         m_eventLoop->exec(QEventLoop::ExcludeUserInputEvents);
+// }
+// 
Index: trunk/BNC/bncsocket.h
===================================================================
--- trunk/BNC/bncsocket.h	(revision 1359)
+++ trunk/BNC/bncsocket.h	(revision 1360)
@@ -35,5 +35,5 @@
   void slotDone(bool);
   void slotRequestFinished(int, bool);
-  void slotReadyRead(const QHttpResponseHeader&);
+  void slotReadyRead();
   void slotSslErrors(const QList<QSslError>&);
 
@@ -45,4 +45,5 @@
   QTcpSocket* _socket;
   QHttp*      _http;      
+  QBuffer*    _buffer;
 };
 
