Index: /trunk/BNC/bncnetqueryv1.cpp
===================================================================
--- /trunk/BNC/bncnetqueryv1.cpp	(revision 1590)
+++ /trunk/BNC/bncnetqueryv1.cpp	(revision 1591)
@@ -158,43 +158,39 @@
   QStringList response;
   while (true) {
-    if (!_socket->waitForReadyRead(_timeOut)) {
-      delete _socket;
-      _socket = 0;
-      _status = error;
-      emit newMessage(_url.path().toAscii() + ": Response timeout", true);
-      return;
-    }
-    if (_socket->canReadLine()) {
-      QString line = _socket->readLine();
-
-      if (line.indexOf("ICY 200 OK") == -1 && 
-          line.indexOf("HTTP")       != -1 && 
-          line.indexOf("200 OK")     != -1 ) {
-        proxyResponse = true;
-      }
-
-      if (!proxyResponse) {
-        response.push_back(line);
-      }
-
-      if (line.indexOf("Unauthorized") != -1) {
+    QByteArray line = this->readNextLine();
+    if (_status == error) {
+      break;
+    }
+
+    cout << ">" << line.data() << "<"; cout.flush();
+
+    if (line.indexOf("ICY 200 OK") == -1 && 
+        line.indexOf("HTTP")       != -1 && 
+        line.indexOf("200 OK")     != -1 ) {
+      proxyResponse = true;
+    }
+
+    if (!proxyResponse && !line.trimmed().isEmpty()) {
+      response.push_back(line);
+    }
+
+    if (line.indexOf("Unauthorized") != -1) {
+      break;
+    }
+
+    if (line.trimmed().isEmpty()) {
+      if (proxyResponse) {
+        proxyResponse = false;
+    	}
+    	else {
         break;
-      }
-
-      if (line.trimmed().isEmpty()) {
-        if (proxyResponse) {
-          proxyResponse = false;
-	}
-	else {
-          break;
-	}
-      }
-
-      if (!proxyResponse                    &&
-          line.indexOf("200 OK")      != -1 &&
-          line.indexOf("SOURCETABLE") == -1) {
-        response.clear();
-	break;
-      }
+    	}
+    }
+
+    if (!proxyResponse                    &&
+        line.indexOf("200 OK")      != -1 &&
+        line.indexOf("SOURCETABLE") == -1) {
+      response.clear();
+      break;
     }
   }
@@ -208,2 +204,30 @@
 }
 
+// 
+////////////////////////////////////////////////////////////////////////////
+QByteArray bncNetQueryV1::readNextLine() {
+  QByteArray buffer;
+  char ch1 = ' ';
+  while (true) {
+    if (_socket->bytesAvailable()) {
+      char ch2;
+      _socket->read(&ch2, 1);
+      if (ch2 != '\r') {
+        buffer += ch2;
+      }
+      if ( (ch2 == '\n' && ch1 == '\r') ||
+           (ch2 == '\r' && ch1 == '\n') ) {
+        return buffer;
+      }
+      ch1 = ch2;
+    }
+    else if (!_socket->waitForReadyRead(_timeOut)) {
+      delete _socket;
+      _socket = 0;
+      _status = error;
+      emit newMessage(_url.path().toAscii() + ": Response timeout", true);
+      return "";
+    }
+  }
+}
+
