Net :: HTTP DELETE调用代理不工作(但得到了)(Net::HTTP DELETE call with a proxy not working (But get does))

编程入门 行业动态 更新时间:2024-10-24 01:53:53
Net :: HTTP DELETE调用代理不工作(但得到了)(Net::HTTP DELETE call with a proxy not working (But get does))

我尝试使用Net :: HTTP与代理和摘要密码进行DELETE。 没有代理,或者如果它是GET,一切都很好。

我有什么想法我做错了怎么办?

带有get的代码工作正常。

h = Net::HTTP.new uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_password req = Net::HTTP::Get.new uri.request_uri res = h.request req

相同的代码并替换为DELETE不起作用

h = Net::HTTP.new uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_password req = Net::HTTP::Delete.new uri.request_uri res = h.request req

我得到了

#<Net::HTTPBadRequest 400 Bad Request readbody=true>

知道可能是什么问题吗? 我需要添加标题还是其他内容?

谢谢

I try to do a DELETE with Net::HTTP with a proxy and a digest password. Everything is working fine without the proxy or if it's a GET.

Any ideas what I'm doing wrong and how to do it?

This code with a get is working fine.

h = Net::HTTP.new uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_password req = Net::HTTP::Get.new uri.request_uri res = h.request req

The same code and replacing with a DELETE is not working

h = Net::HTTP.new uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_password req = Net::HTTP::Delete.new uri.request_uri res = h.request req

I get a

#<Net::HTTPBadRequest 400 Bad Request readbody=true>

Any idea what could be the problem? Do I need to add a header or something?

Thanks

最满意答案

我发现了我的问题。

我需要为内容类型添加一个主体。

h = Net::HTTP.new uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_password req = Net::HTTP::Delete.new uri.request_uri req.body = "Content-type: application/xml" res = h.request req

它现在有效。

I found my problem.

I needed to add a body for content-type.

h = Net::HTTP.new uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_password req = Net::HTTP::Delete.new uri.request_uri req.body = "Content-type: application/xml" res = h.request req

And it works now.

更多推荐

Net,HTTP,req,电脑培训,计算机培训,IT培训"/> <meta name="description"

本文发布于:2023-08-02 18:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1379666.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:得到了   工作   DELETE   Net   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!