Skip to content

Commit

Permalink
Revert "Merge pull request #248 from braxtone/master"
Browse files Browse the repository at this point in the history
This reverts commit cf9ee3f, reversing
changes made to a36787f.

Additonally, these follow-up commits are reverted:
1a8418e

9b9cbde
  • Loading branch information
gschneider-r7 committed Oct 26, 2016
1 parent 9b9cbde commit d2c5759
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions lib/nexpose/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,38 +94,24 @@ def execute(xml, version = '1.1', options = {})
end

# Download a specific URL, typically a report.
# Include an optional file_name parameter to stream the output to a file.
# Pass a block to get the response as it is returned from the server
# Include an optional file_name parameter to write the output to a file.
#
# Note: XML and HTML reports have charts not downloaded by this method.
# Would need to do something more sophisticated to grab
# all the associated image files.
def download(url, file_name = nil)
return nil if url.nil? or url.empty?
uri = URI.parse(url)

http = Net::HTTP.new(@host, @port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # XXX: security issue
headers = {'Cookie' => "nexposeCCSessionID=#{@session_id}"}
resp = http.get(uri.to_s, headers)

Net::HTTP.start(@host, @port,
use_ssl: true,
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
request = Net::HTTP::Get.new(uri.to_s, headers)

http.request(request) do |response|
if file_name
::File.open(file_name, 'wb') do |f|
response.read_body do |chunk|
f.write chunk
end
end
elsif block_given?
response.read_body do |chunk|
yield chunk
end
else
return response.body
end
end
if file_name
::File.open(file_name, 'wb') { |file| file.write(resp.body) }
else
resp.body
end
end
end
Expand Down

0 comments on commit d2c5759

Please sign in to comment.