onDataRead = function(data) {
      requestData += arrayBufferToString(data).replace(/\r\n/g, '\n');
      // Check for end of request.
      endIndex = requestData.indexOf('\n\n', endIndex);
      if (endIndex == -1) {
        endIndex = requestData.length - 1;
        return pSocket.read().then(onDataRead);
      }

      var headers = requestData.substring(0, endIndex).split('\n');
      var headerMap = {};
      // headers[0] should be the Request-Line
      var requestLine = headers[0].split(' ');
      headerMap['method'] = requestLine[0];
      headerMap['url'] = requestLine[1];
      headerMap['Http-Version'] = requestLine[2];
      for (var i = 1; i < headers.length; i++) {
        requestLine = headers[i].split(':', 2);
        if (requestLine.length == 2)
          headerMap[requestLine[0]] = requestLine[1].trim();
      }
      var request = new HttpRequest(headerMap, pSocket);
      t.onRequest_(request);
    }
Listen for connections on |port| using the interface |host|.
@param {number} port The port to listen for incoming connections on.
@param {string=} opt_host The host interface to listen for connections on.
    This will default to 0.0.0.0 if not specified which will listen on
    all interfaces.