[英]405 Method not allowed on Net::HTTP request [ruby on rails]
我正在尝试验证是否存在具有以下代码的远程URL:
endpoint_uri = URI.parse(@endpoint.url)
endpoint_http = Net::HTTP.new(endpoint_uri.host, endpoint_uri.port)
endpoint_request = Net::HTTP::Head.new(endpoint_uri.request_uri)
endpoint_response = endpoint_http.request(endpoint_request)
我仍然没有获得405方法。 当我使用Get
代替Head
in Net::HTTP::Head.new
我得到200成功,但是整个远程文档都响应了,这导致响应时间Net::HTTP::Head.new
(0.3s => 0.9s)。
任何想法为什么会这样? 谢谢
您尝试与之交互的@endpoint
URL可能不支持HEAD请求(这确实很奇怪,但实际情况仍然如此)。 您的代码对我来说适合一些网址(google.com,stackoverflow.com等)
您是否尝试过卷曲请求以查看它返回的内容?
curl -I http://www.the_website_you_want_to_test.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.