我想通过代理在rails上的ruby中运行以下命令:
curl --request POST http://200.206.38.24:8580/my_server_path/
--data-binary @test01.xml
--header "Content-type: Application/vnd.vizrt.payload+xml;type=element"
到目前为止,我有:
PROXY_URL = 'proxy.mydomain.com'
PROXY_PORT = 3128
PROXY_USER = 'user'
PROXY_PASSWORD = 'pass'
MSE_HOST = '200.206.38.24'
MSE_PORT = 8580
MSE_PATH = '/my_server_path/'
xml_file = '<?xml version="1.0" encoding="utf-8"?><etc... />'
Net::HTTP::Proxy(PROXY_URL, PROXY_PORT, PROXY_USER, PROXY_PASSWORD).start(MSE_HOST, MSE_PORT) do |http|
response = http.post(MSE_PATH, xml_file, {"Content-type" => "Application/vnd.vizrt.payload+xml;type=element"})
end
提前感谢您的帮助。
答案 0 :(得分:0)
根据测试,它工作正常。 http.post的响应可以通过body方法访问。例如:response.body