From: Todd Williams Date: 2008-09-27T07:59:17+09:00 Subject: save http response file attachment I'm looking for some samples on saving off an attached file from a response to an HTTPS Post. Here's what I got so far. I was hoping that read_body would be able to use the block keep pulling the data but all I get out of this is the first line of the file. Any help would be appreciated. ----- require 'uri' require 'net/https' uri = URI.parse("https://somewhere.com") request = Net::HTTP::Post.new(uri.path) params = Hash.new params["userId"] = "xxxx" params["userPass"] = "yyyy" params["reportDateBegin"] = "08%2F01%2F2008" params["reportDateEnd"] = "08%2F25%2F2008" params["reportType"] = "1" request.set_form_data(params) begin http_session = Net::HTTP.new(uri.host, uri.port) http_session.use_ssl = true http_session.verify_mode = OpenSSL::SSL::VERIFY_NONE http_session.request(request) do |response| puts response.content_type response.read_body do |segment| #TODO save off information to file puts segment end end rescue Exception => e puts e.to_s end -- Posted via http://www.ruby-forum.com/.