這是我的代碼。如何在Ruby Net :: HTTP中實現Cookie
現在我需要發送一個cookie到主機,但我找不到解決方案。
def get_network_file(url=nil)
begin
http = Net::HTTP.new(@service_server, 80)
resp, data = http.get(url, { "Accept-Language" => @locale })
if resp.code.to_i != 200
RAILS_DEFAULT_LOGGER.error "*** return code != 200. code = #{resp.code}"
return ""
end
rescue Exception => exc
RAILS_DEFAULT_LOGGER.error "*** message --> #{exc.message}"
return ""
end
return data
end
end
[如何實現的cookie可能重複餅乾支持在紅寶石網/ http?](http://stackoverflow.com/questions/1486703/how-to-implement-cookie-support-in-ruby-net-http) – 2013-03-11 20:12:00