From: Hunter Mcmillen Date: 2011-07-22T02:42:59+09:00 Subject: Issue downloading an image from a URL (HTTP request) I am trying to download the image of a chart I created using the GoogleChart API using the 'net/http' module. I have the URL I want to download the image from stored in a string variable named failures_url, when I use the variable to download the image it doesn't work. But if I use the string literal value of that variable it does work. This is what I am doing: require 'net/http' #try with variable Net::HTTP.start("http://chart.googleapis.com") { |http| resp = http.get("/chart?#{failures_url}") open("pie1.png" ,"wb") { |file| file.write(resp.body) } } the value of failures_url is: "chtt=Failure+By+Type+Over+Last+Year&cht=p &chd=t:26.8720821661998,25.6022408963585,24.9859943977591, 17.9831932773109,2.80112044817927,0.65359477124183,0.354808590102708, 0.336134453781513,0.224089635854342,0.168067226890756, 0.130718954248366,0.0373482726423903&chs=700x400& chco=4466AA|9BC4E2|1464F4|0000FF|63D1F4|388E8E& chl=Build/Compile+Failure+26.87%|Unknown+Failure+25.6%| User+Manifest+Failure+24.99%|Invalid+Clientspec+17.98%| Incomplete+Build+2.8%|Coverity+System+Error+0.65%| Do+Not+Use+Error+0.35%|Version+Failure+0.34%|Coverity+Defects+0.22%| Flash+Build+Error+0.17%|Space+Insufficient+0.13%|Integrate+Failure+0.04%" This attempt does not work. #2nd attempt with string literal Net::HTTP.start("http://chart.googleapis.com") { |http| resp = http.get("/chart?chtt=Failure+By+Type+Over+Last+Year&cht=p&chd=t:26.8720821661998,25.6022408963585,24.9859943977591,17.9831932773109,2.80112044817927,0.65359477124183,0.354808590102708,0.336134453781513,0.224089635854342,0.168067226890756,0.130718954248366,0.0373482726423903&chs=700x400&chco=4466AA|9BC4E2|1464F4|0000FF|63D1F4|388E8E&chl=Build/Compile+Failure+26.87%|Unknown+Failure+25.6%|User+Manifest+Failure+24.99%|Invalid+Clientspec+17.98%|Incomplete+Build+2.8%|Coverity+System+Error+0.65%|Do+Not+Use+Error+0.35%|Version+Failure+0.34%|Coverity+Defects+0.22%|Flash+Build+Error+0.17%|Space+Insufficient+0.13%|Integrate+Failure+0.04%") open("pie2.png" ,"wb") { |file| file.write(resp.body) } } This attempt DOES work. Does anyone know why this is happening? The value is the same in both http.get(...) calls but only the literal one generates an image file. Thanks Hunter -- Posted via http://www.ruby-forum.com/.