got it ungzipping gzip stream and the get works

This commit is contained in:
booboy 2019-05-11 18:07:09 -05:00
parent 7ba4928770
commit c3755a71d3

View file

@ -1,4 +1,6 @@
require 'rest-client'
require 'zlib'
require 'json'
class NvdDownloader
attr_accessor :base_url, :years
@ -22,9 +24,18 @@ class NvdDownloader
years[year]
end
def get(url)
r = RestClient.get "#{base_url}#{url}"
r.body if r.code == 200
end
def read_gzip_stream(gzip_stream)
io_stream = StringIO.new(gzip_stream)
gz = Zlib::GzipReader.new(io_stream)
gz.read
end
def parse_json(json_string)
JSON.parse(json_string)
end
end