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 reqThe 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 reqI 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 reqAnd it works now.
更多推荐
Net,HTTP,req,电脑培训,计算机培训,IT培训"/> <meta name="description"
发布评论