Ruby on Rails HTTPS发布错误请求 [英] Ruby on Rails HTTPS Post Bad Request
问题描述
致以问候。
我的应用程序适用于远程服务器。服务器使用证书的https
授权。我有以下代码进行授权,
发送请求:
My application works with a remote server. Server uses https authorization of the certificate. I have following code to authorize and sends request:
uri = URI.parse("https://db1-test.content.ertelecom.ru/")
http = Net::HTTP.new(uri.host, '443')
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.ca_file = File.join(File.dirname("public/certificate.pem"),
"certificate.pem")
http.start do |http|
req =
Net::HTTP::Get.new("/cgi-bin/expr/export.get_pay_systems?partner_id=1003")
responce = http.request(req)
resp = responce.body
end
此代码运作良好,我得到了来自服务器的数据。但是当我尝试
发出POST请求时:
this code works well, I get the data from the server. BUT when I try to make POST request:
http.start do |http|
req =
Net::HTTP::Post.new("/cgi-bin/expr/payment_transactions.verify_order",
params)
responce = http.request(req)
resp = responce.body
end
我收到错误server:
I get an error from the server:
Your browser sent a request that this server could not understand.
Request header field is missing ':' separator.
那是什么?我试图找到解决方案,但无济于事。
互联网上传出的消息是它可能是防病毒软件,但我的价格是b $ b Linux。我会很高兴有任何想法!
what is that be? I tried to find a solution, but to no avail. the Internet caught the message that it could be antivirus, but I'm on Linux. I will be glad to any thoughts!
推荐答案
你没有填写标题数据。
你可以使用Net :: HTTP.post_form方法创建你的请求或自己填充form_data。
You could either use the Net::HTTP.post_form method to create your request or populate the form_data yourself.
post_form解决方案:
post_form solution:
req = NET::HTTP.post_form("/cgi-bin/expr/payment_transactions.verify_order", params)
手动form_data人口
manual form_data population
req =
Net::HTTP::Post.new("/cgi-bin/expr/payment_transactions.verify_order")
req.set_form_data(params)
这篇关于Ruby on Rails HTTPS发布错误请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!