Ruby on Rails HTTPS 发布错误请求

发布于 2024-08-10 18:26:00 字数 993 浏览 5 评论 0原文

大家好。

我的应用程序与远程服务器一起使用。服务器使用https 证书的授权。我有以下代码来授权和 发送请求:

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 请求:

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

我从服务器收到错误:

Your browser sent a request that this server could not understand.
Request header field is missing ':' separator.

那是什么?我试图寻找解决方案,但无济于事。这 互联网发现它可能是防病毒的消息,但我在 Linux。我会很高兴有任何想法!

Greetings all.

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

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

I get an error from the server:

Your browser sent a request that this server could not understand.
Request header field is missing ':' separator.

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜心小果奶 2024-08-17 18:26:00

您没有填写标题数据。

您可以使用 Net::HTTP.post_form 方法创建请求或自己填充 form_data。

post_form解决方案:

req = NET::HTTP.post_form("/cgi-bin/expr/payment_transactions.verify_order", params)

手动form_data填充

req =
  Net::HTTP::Post.new("/cgi-bin/expr/payment_transactions.verify_order")
req.set_form_data(params)

You're not filling the header data.

You could either use the Net::HTTP.post_form method to create your request or populate the form_data yourself.

post_form solution:

req = NET::HTTP.post_form("/cgi-bin/expr/payment_transactions.verify_order", params)

manual form_data population

req =
  Net::HTTP::Post.new("/cgi-bin/expr/payment_transactions.verify_order")
req.set_form_data(params)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文