mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Use mount_proc to avoid the delay of writing data to files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									223e0212e9
								
							
						
					
					
						commit
						3f443e6115
					
				
					 2 changed files with 12 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -52,7 +52,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
  def test_200
 | 
			
		||||
    with_http {|srv, dr, url|
 | 
			
		||||
      open("#{dr}/foo200", "w") {|f| f << "foo200" }
 | 
			
		||||
      srv.mount_proc("/foo200", lambda { |req, res| res.body = "foo200" } )
 | 
			
		||||
      open("#{url}/foo200") {|f|
 | 
			
		||||
        assert_equal("200", f.status[0])
 | 
			
		||||
        assert_equal("foo200", f.read)
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
  def test_200big
 | 
			
		||||
    with_http {|srv, dr, url|
 | 
			
		||||
      content = "foo200big"*10240
 | 
			
		||||
      open("#{dr}/foo200big", "w") {|f| f << content }
 | 
			
		||||
      srv.mount_proc("/foo200big", lambda { |req, res| res.body = content } )
 | 
			
		||||
      open("#{url}/foo200big") {|f|
 | 
			
		||||
        assert_equal("200", f.status[0])
 | 
			
		||||
        assert_equal(content, f.read)
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
  def test_open_uri
 | 
			
		||||
    with_http {|srv, dr, url|
 | 
			
		||||
      open("#{dr}/foo_ou", "w") {|f| f << "foo_ou" }
 | 
			
		||||
      srv.mount_proc("/foo_ou", lambda { |req, res| res.body = "foo_ou" } )
 | 
			
		||||
      u = URI("#{url}/foo_ou")
 | 
			
		||||
      open(u) {|f|
 | 
			
		||||
        assert_equal("200", f.status[0])
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +124,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
  def test_mode
 | 
			
		||||
    with_http {|srv, dr, url|
 | 
			
		||||
      open("#{dr}/mode", "w") {|f| f << "mode" }
 | 
			
		||||
      srv.mount_proc("/mode", lambda { |req, res| res.body = "mode" } )
 | 
			
		||||
      open("#{url}/mode", "r") {|f|
 | 
			
		||||
        assert_equal("200", f.status[0])
 | 
			
		||||
        assert_equal("mode", f.read)
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +146,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
  def test_without_block
 | 
			
		||||
    with_http {|srv, dr, url|
 | 
			
		||||
      open("#{dr}/without_block", "w") {|g| g << "without_block" }
 | 
			
		||||
      srv.mount_proc("/without_block", lambda { |req, res| res.body = "without_block" } )
 | 
			
		||||
      begin
 | 
			
		||||
        f = open("#{url}/without_block")
 | 
			
		||||
        assert_equal("200", f.status[0])
 | 
			
		||||
| 
						 | 
				
			
			@ -197,8 +197,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
      proxy_url = "http://#{proxy_host}:#{proxy_port}/"
 | 
			
		||||
      begin
 | 
			
		||||
        proxy.start
 | 
			
		||||
        open("#{dr}/proxy", "w") {|f| f << "proxy" }
 | 
			
		||||
        sleep 0.5
 | 
			
		||||
        srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
 | 
			
		||||
        open("#{url}/proxy", :proxy=>proxy_url) {|f|
 | 
			
		||||
          assert_equal("200", f.status[0])
 | 
			
		||||
          assert_equal("proxy", f.read)
 | 
			
		||||
| 
						 | 
				
			
			@ -251,7 +250,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
      proxy_url = "http://#{proxy_host}:#{proxy_port}/"
 | 
			
		||||
      begin
 | 
			
		||||
        proxy.start
 | 
			
		||||
        open("#{dr}/proxy", "w") {|f| f << "proxy" }
 | 
			
		||||
        srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
 | 
			
		||||
        exc = assert_raise(OpenURI::HTTPError) { open("#{url}/proxy", :proxy=>proxy_url) {} }
 | 
			
		||||
        assert_equal("407", exc.io.status[0])
 | 
			
		||||
        assert_match(/#{Regexp.quote url}/, log); log.clear
 | 
			
		||||
| 
						 | 
				
			
			@ -420,7 +419,7 @@ class TestOpenURI < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
  def test_uri_read
 | 
			
		||||
    with_http {|srv, dr, url|
 | 
			
		||||
      open("#{dr}/uriread", "w") {|f| f << "uriread" }
 | 
			
		||||
      srv.mount_proc("/uriread", lambda { |req, res| res.body = "uriread" } )
 | 
			
		||||
      data = URI("#{url}/uriread").read
 | 
			
		||||
      assert_equal("200", data.status[0])
 | 
			
		||||
      assert_equal("uriread", data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ class TestOpenURISSL < Test::Unit::TestCase
 | 
			
		|||
        :Port => 0})
 | 
			
		||||
      _, port, _, host = srv.listeners[0].addr
 | 
			
		||||
      begin
 | 
			
		||||
        th = srv.start
 | 
			
		||||
        srv.start
 | 
			
		||||
        yield srv, dr, "https://#{host}:#{port}"
 | 
			
		||||
      ensure
 | 
			
		||||
        srv.shutdown
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ class TestOpenURISSL < Test::Unit::TestCase
 | 
			
		|||
    with_https {|srv, dr, url|
 | 
			
		||||
      cacert_filename = "#{dr}/cacert.pem"
 | 
			
		||||
      open(cacert_filename, "w") {|f| f << CA_CERT }
 | 
			
		||||
      open("#{dr}/data", "w") {|f| f << "ddd" }
 | 
			
		||||
      srv.mount_proc("/data", lambda { |req, res| res.body = "ddd" } )
 | 
			
		||||
      open("#{url}/data", :ssl_ca_cert => cacert_filename) {|f|
 | 
			
		||||
        assert_equal("200", f.status[0])
 | 
			
		||||
        assert_equal("ddd", f.read)
 | 
			
		||||
| 
						 | 
				
			
			@ -77,8 +77,8 @@ class TestOpenURISSL < Test::Unit::TestCase
 | 
			
		|||
        :Port => 0})
 | 
			
		||||
      _, p_port, _, p_host = prxy.listeners[0].addr
 | 
			
		||||
      begin
 | 
			
		||||
        th = prxy.start
 | 
			
		||||
        open("#{dr}/proxy", "w") {|f| f << "proxy" }
 | 
			
		||||
        prxy.start
 | 
			
		||||
        srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
 | 
			
		||||
        open("#{url}/proxy", :proxy=>"http://#{p_host}:#{p_port}/", :ssl_ca_cert => cacert_filename) {|f|
 | 
			
		||||
          assert_equal("200", f.status[0])
 | 
			
		||||
          assert_equal("proxy", f.read)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue