protected function readResponseContentChunk(&$document_completed, &$error_code, &$error_string, &$document_received_completely)
  { 
    $source_chunk = "";
    $stop_receiving = false;
    $bytes_received = 0;
    $document_completed = false;
    
    // If chunked encoding and protocol to use is HTTP 1.1
    if ($this->http_protocol_version == PHPCrawlerHTTPProtocols::HTTP_1_1 && $this->lastResponseHeader->transfer_encoding == "chunked")
    {
      // Read size of next chunk
      $chunk_line = @fgets($this->socket, 128);
      if (trim($chunk_line) == "") $chunk_line = @fgets($this->socket, 128);
      $current_chunk_size = hexdec(trim($chunk_line));
    }
    else
    {
      $current_chunk_size = $this->chunk_buffer_size;
    }
    
    if ($current_chunk_size === 0)
    {
      $stop_receiving = true;
      $document_completed = true;
    }
    
    while ($stop_receiving == false)
    {
      socket_set_timeout($this->socket, $this->socketReadTimeout);
      
      // Set byte-buffer to bytes in socket-buffer (Fix for SSL-hang-bug #56, thanks to MadEgg!)
      $status = socket_get_status($this->socket);
      if ($status["unread_bytes"] > 0)
        $read_byte_buffer = $status["unread_bytes"];
      else
        $read_byte_buffer = $this->socket_read_buffer_size;
      
      // If chunk will be complete next read -> resize read-buffer to size of remaining chunk
      if ($bytes_received + $read_byte_buffer >= $current_chunk_size && $current_chunk_size > 0)
      {
        $read_byte_buffer = $current_chunk_size - $bytes_received;
        $stop_receiving = true;
      }
      
      // Read line from socket
      $line_read = @fread($this->socket, $read_byte_buffer); 
      
      $source_chunk .= $line_read;
      $line_length = strlen($line_read);
      $this->content_bytes_received += $line_length;
      $this->global_traffic_count += $line_length;
      $bytes_received += $line_length;
      
      // Check socket-status
      $status = socket_get_status($this->socket);
      
      // Check for EOF
      if ($status["unread_bytes"] == 0 && ($status["eof"] == true || feof($this->socket) == true))
      {
        $stop_receiving = true;
        $document_completed = true;
      }
      
      // Socket timed out
      if ($status["timed_out"] == true)
      {
        $stop_receiving = true;
        $document_completed = true;
        $error_code = PHPCrawlerRequestErrors::ERROR_SOCKET_TIMEOUT;
        $error_string = "Socket-stream timed out (timeout set to ".$this->socketReadTimeout." sec).";
        $document_received_completely = false;
        return $source_chunk;
      }

      // Check if content-length stated in the header is reached
      if ($this->lastResponseHeader->content_length == $this->content_bytes_received)
      {
        $stop_receiving = true;
        $document_completed = true;
      }
      
      // Check if contentsize-limit is reached
      if ($this->content_size_limit > 0 && $this->content_size_limit <= $this->content_bytes_received)
      {
        $document_received_completely = false;
        $stop_receiving = true;
        $document_completed = true;
      }
      
    }
    
    return $source_chunk;
  }