Skip to content

Commit

Permalink
Merge pull request #2 from ninoseki/update-outout-format
Browse files Browse the repository at this point in the history
feat: update output format
  • Loading branch information
ninoseki committed Jun 16, 2020
2 parents cbc61f0 + 8303159 commit b6c9ee6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/rangescan/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ def get(ipv4)

begin
res = HTTP.timeout(timeout).headers(default_headers).get(url, ssl_options)
{ ipv4: ipv4, code: res.code, body: res.body.to_s }
{
url: url,
ipv4: ipv4,
code: res.code,
headers: res.headers.to_h,
body: res.body.to_s
}
rescue StandardError
nil
end
Expand Down
8 changes: 8 additions & 0 deletions spec/range_scan/scanner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,13 @@ def server
results = scanner.scan([host])
expect(results.first.dig(:body)).to eq("foo")
end

it do
scanner = described_class.new(port: port)
results = scanner.scan([host])

first = results.first
[:url, :ipv4, :code, :headers, :body].all? { |key| first.key? key }
end
end
end

0 comments on commit b6c9ee6

Please sign in to comment.