Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
save http response file attachment
Todd Williams
9/26/2008 10:59:00 PM
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...
)
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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
save http response file attachment
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password