Author: Frédéric de Villamil Date: Sun Jun 28 15:01:05 2009 +0200 Fixing a bug where vendor/flickr/flickr.rb could not handle 302 response. Closes ticket #106 diff --git a/vendor/flickr/flickr.rb b/vendor/flickr/flickr.rb index 4728132..a5e5352 100644 --- a/vendor/flickr/flickr.rb +++ b/vendor/flickr/flickr.rb @@ -45,8 +45,8 @@ # - make a kickass demo, including autocompleting-ajax photo lookup ala http://mir.aculo.us/images/autocomplete1.mov require 'cgi' -require 'net/http' +require 'open-uri' require 'xmlsimple' # Flickr client class. Requires an API key, and optionally takes an email and password for authentication class Flickr @@ -78,7 +78,7 @@ class Flickr # Does an HTTP GET on a given URL and returns the response body def http_get(url) - Net::HTTP.get_response(URI.parse(url)).body.to_s + open(URI.parse(url)) {|h| h.read } end # Stores authentication credentials to use on all subsequent calls. @@ -318,7 +318,7 @@ class Flickr # Returns the photo file data itself, in any specified size. Example: File.open(photo.title, 'w') { |f| f.puts photo.file } def file(size='Medium') - Net::HTTP.get_response(URI.parse(source(size))).body + open(URI.parse(source(size))) {|h| h.read } end # Unique filename for the image, based on the Flickr NSID