ruby-changes:13122
From: akr <ko1@a...>
Date: Sun, 13 Sep 2009 00:34:45 +0900 (JST)
Subject: [ruby-changes:13122] Ruby:r24872 (trunk): test invalid redirect location.
akr 2009-09-13 00:34:35 +0900 (Sun, 13 Sep 2009) New Revision: 24872 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24872 Log: test invalid redirect location. Modified files: trunk/test/open-uri/test_open-uri.rb Index: test/open-uri/test_open-uri.rb =================================================================== --- test/open-uri/test_open-uri.rb (revision 24871) +++ test/open-uri/test_open-uri.rb (revision 24872) @@ -240,10 +240,36 @@ assert_equal("ab\r\n", content) ensure Thread.kill(th) + th.join end } end + def test_redirect_invalid + TCPServer.open("127.0.0.1", 0) {|serv| + port = serv.addr[1] + th = Thread.new { + sock = serv.accept + begin + req = sock.gets("\r\n\r\n") + assert_match(%r{\AGET /foo/bar }, req) + sock.print "HTTP/1.0 302 Found\r\n" + sock.print "Location: ::\r\n\r\n" + ensure + sock.close + end + } + begin + assert_raise(OpenURI::HTTPError) { + URI("http://127.0.0.1:#{port}/foo/bar").read + } + ensure + Thread.kill(th) + th.join + end + } + end + def test_redirect_auth with_http {|srv, dr, url| srv.mount_proc("/r1/") {|req, res| res.status = 301; res["location"] = "#{url}/r2" } @@ -456,6 +482,7 @@ assert_equal("content", content) ensure Thread.kill(th) + th.join end } end @@ -482,6 +509,7 @@ } ensure Thread.kill(th) + th.join end } end @@ -508,6 +536,7 @@ assert_equal("ab\r\n", content) ensure Thread.kill(th) + th.join end } end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/