def generate(connection, timeout = 300, raw = false)
      xml = %(<ReportAdhocGenerateRequest session-id="#{connection.session_id}">)
      xml << to_xml
      xml << '</ReportAdhocGenerateRequest>'
      response = connection.execute(xml, '1.1', timeout: timeout, raw: raw)
      if response.success
        content_type_response = response.raw_response.header['Content-Type']
        if content_type_response =~ /multipart\/mixed;\s*boundary=([^\s]+)/
          # Nexpose sends an incorrect boundary format which breaks parsing
          # e.g., boundary=XXX; charset=XXX
          # Fix by removing everything from the last semi-colon onward.
          last_semi_colon_index = content_type_response.index(/;/, content_type_response.index(/boundary/))
          content_type_response = content_type_response[0, last_semi_colon_index]

          data = 'Content-Type: ' + content_type_response + "\r\n\r\n" + response.raw_response_data
          doc = Rexlite::MIME::Message.new(data)
          doc.parts.each do |part|
            if /.*base64.*/ =~ part.header.to_s
              if @format =~ /(?:ht|x)ml/
                if part.header.to_s =~ %r(text/xml)
                  return part.content.unpack('m*')[0].to_s
                elsif part.header.to_s =~ %r(text/html)
                  return part.content.unpack('m*')[0].to_s
                end
              else # text|pdf|csv|rtf
                return part.content.unpack('m*')[0]
              end
            end
          end
        end
      end
    end
def generate(connection, timeout = 300, raw = false)
      xml = %(<ReportAdhocGenerateRequest session-id="#{connection.session_id}">)
      xml << to_xml
      xml << '</ReportAdhocGenerateRequest>'
      response = connection.execute(xml, '1.1', timeout: timeout, raw: raw)
      if response.success
        content_type_response = response.raw_response.header['Content-Type']
        if content_type_response =~ /multipart\/mixed;\s*boundary=([^\s]+)/
          # Nexpose sends an incorrect boundary format which breaks parsing
          # e.g., boundary=XXX; charset=XXX
          # Fix by removing everything from the last semi-colon onward.
          last_semi_colon_index = content_type_response.index(/;/, content_type_response.index(/boundary/))
          content_type_response = content_type_response[0, last_semi_colon_index]

          data = 'Content-Type: ' + content_type_response + "\r\n\r\n" + response.raw_response_data
          doc = Rexlite::MIME::Message.new(data)
          doc.parts.each do |part|
            if /.*base64.*/ =~ part.header.to_s
              if @format =~ /(?:ht|x)ml/
                if part.header.to_s =~ %r(text/xml)
                  return part.content.unpack('m*')[0].to_s
                elsif part.header.to_s =~ %r(text/html)
                  return part.content.unpack('m*')[0].to_s
                end
              else # text|pdf|csv|rtf
                return part.content.unpack('m*')[0]
              end
            end
          end
        end
      end
    end
Generate a report once using a simple configuration.

 For XML-based reports, only the textual report is returned and not any images.

 @param [Connection] connection Nexpose connection.
 @param [Fixnum] timeout How long, in seconds, to wait for the report to
   generate. Larger reports can take a significant amount of time.
 @param [Boolean] raw Whether to bypass response parsing an use the raw
   response. If this option is used, error will only be exposed by
   examining Connection#response_xml.
 @return Report in text format except for PDF, which returns binary data.