mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-08-10 00:01:04 -04:00
Use Addressable's inferred_port instead of port so that SSL works. Fixes #23
This commit is contained in:
parent
eb398e46c7
commit
bad3608afd
@ -230,7 +230,7 @@ class FastImage
|
||||
Fiber.yield str
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
parse_packets
|
||||
|
||||
break # needed to actively quit out of the fetch
|
||||
@ -250,11 +250,10 @@ class FastImage
|
||||
proxy = proxy_uri
|
||||
|
||||
if proxy
|
||||
@http = Net::HTTP::Proxy(proxy.host, proxy.port).new(@parsed_uri.host, @parsed_uri.port)
|
||||
@http = Net::HTTP::Proxy(proxy.host, proxy.port).new(@parsed_uri.host, @parsed_uri.inferred_port)
|
||||
else
|
||||
@http = Net::HTTP.new(@parsed_uri.host, @parsed_uri.port)
|
||||
@http = Net::HTTP.new(@parsed_uri.host, @parsed_uri.inferred_port)
|
||||
end
|
||||
|
||||
@http.use_ssl = (@parsed_uri.scheme == "https")
|
||||
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
@http.open_timeout = @timeout
|
||||
@ -283,7 +282,7 @@ class FastImage
|
||||
@strpos = 0
|
||||
@bytes_read = 0
|
||||
@bytes_delivered = 0
|
||||
|
||||
|
||||
begin
|
||||
result = send("parse_#{@property}")
|
||||
if result
|
||||
|
@ -36,6 +36,9 @@ LargeImage = "http://upload.wikimedia.org/wikipedia/commons/b/b4/Mardin_1350660_
|
||||
LargeImageInfo = [:jpeg, [9545, 6623]]
|
||||
LargeImageFetchLimit = 2 # seconds
|
||||
|
||||
HTTPSImage = "https://upload.wikimedia.org/wikipedia/commons/b/b4/Mardin_1350660_1350692_33_images.jpg"
|
||||
HTTPSImageInfo = [:jpeg, [9545, 6623]]
|
||||
|
||||
GoodFixtures.each do |fn, info|
|
||||
FakeWeb.register_uri(:get, "#{TestUrl}#{fn}", :body => File.join(FixturePath, fn))
|
||||
end
|
||||
@ -222,4 +225,9 @@ class FastImageTest < Test::Unit::TestCase
|
||||
ENV['http_proxy'] = nil
|
||||
assert_equal actual_size, size
|
||||
end
|
||||
|
||||
def test_should_handle_https_image
|
||||
size = FastImage.size(HTTPSImage)
|
||||
assert_equal HTTPSImageInfo[1], size
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user