Ruby - net/http - following redirects

后端 未结 6 1063
北恋
北恋 2020-12-01 03:05

I\'ve got a URL and I\'m using HTTP GET to pass a query along to a page. What happens with the most recent flavor (in net/http) is that the script doesn\'t go

6条回答
  •  余生分开走
    2020-12-01 03:31

    The reference that worked for me is here: http://shadow-file.blogspot.co.uk/2009/03/handling-http-redirection-in-ruby.html

    Compared to most examples (including the accepted answer here), it's more robust as it handles URLs which are just a domain (http://example.com - needs to add a /), handles SSL specifically, and also relative URLs.

    Of course you would be better off using a library like RESTClient in most cases, but sometimes the low-level detail is necessary.

提交回复
热议问题