diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-02-09 07:04:13 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-02-09 09:55:04 +0000 |
commit | b96d1018ae5261d8ee9344b959acb04c1be43279 (patch) | |
tree | 1681ca61673508fc0fbf6407c648527626710e54 | |
parent | 7d740e5825e05030b5978ed296fd0b801666b405 (diff) | |
download | cmogstored-b96d1018ae5261d8ee9344b959acb04c1be43279.tar.gz |
Unused variables and unset Content-Type for Net::HTTP requests
-rw-r--r-- | test/http.rb | 1 | ||||
-rw-r--r-- | test/http_dav.rb | 16 | ||||
-rw-r--r-- | test/http_getonly.rb | 4 | ||||
-rw-r--r-- | test/test_helper.rb | 6 |
4 files changed, 16 insertions, 11 deletions
diff --git a/test/http.rb b/test/http.rb index 6bfe659..4a6f2a1 100644 --- a/test/http.rb +++ b/test/http.rb @@ -53,7 +53,6 @@ class TestHTTP < Test::Unit::TestCase # ensure HTTP HEAD responses get pushed right away def test_head_response_time File.open("#@tmpdir/somefile", "wb") { |fp| fp.puts "HI\n" } - st = File.stat("#@tmpdir/somefile") Net::HTTP.start(@host, @port) do |http| req = Net::HTTP::Head.new("/somefile") t0 = Time.now diff --git a/test/http_dav.rb b/test/http_dav.rb index 0cab527..d22c00d 100644 --- a/test/http_dav.rb +++ b/test/http_dav.rb @@ -39,31 +39,31 @@ class TestHTTPDav < Test::Unit::TestCase def test_mkcol_delete Net::HTTP.start(@host, @port) do |http| assert ! File.directory?("#@tmpdir/foo") - assert_equal 400, http.request(Net::HTTP::Mkcol.new("/foo")).code.to_i + assert_equal 400, http.request(new_req(:Mkcol, "/foo")).code.to_i assert ! File.directory?("#@tmpdir/foo") Dir.mkdir("#@tmpdir/foo") File.open("#@tmpdir/foo/a", "w").close - resp = http.request(Net::HTTP::Delete.new("/foo/a")) + resp = http.request(new_req(:Delete, "/foo/a")) assert_equal 204, resp.code.to_i assert ! File.exist?("#@tmpdir/foo/a") - resp = http.request(Net::HTTP::Delete.new("/foo/a")) + resp = http.request(new_req(:Delete, "/foo/a")) assert_equal 404, resp.code.to_i - resp = http.request(Net::HTTP::Delete.new("/foo")) + resp = http.request(new_req(:Delete, "/foo")) assert_equal 403, resp.code.to_i - resp = http.request(Net::HTTP::Delete.new("../foo")) + resp = http.request(new_req(:Delete, "../foo")) assert_equal 400, resp.code.to_i - resp = http.request(Net::HTTP::Mkcol.new("../foo")) + resp = http.request(new_req(:Mkcol, "../foo")) assert_equal 400, resp.code.to_i - resp = http.request(Net::HTTP::Delete.new("/")) + resp = http.request(new_req(:Delete, "/")) assert_equal 403, resp.code.to_i - resp = http.request(Net::HTTP::Delete.new("//")) + resp = http.request(new_req(:Delete, "//")) assert_equal 403, resp.code.to_i end end diff --git a/test/http_getonly.rb b/test/http_getonly.rb index c26815f..8f8ebb3 100644 --- a/test/http_getonly.rb +++ b/test/http_getonly.rb @@ -68,11 +68,11 @@ class TestHTTPGetOnly < Test::Unit::TestCase assert_equal "HIHI\n", resp.body assert_equal "keep-alive", resp["Connection"] - resp = http.request(Net::HTTP::Delete.new("/dev666/test-file")) + resp = http.request(new_req(:Delete, "/dev666/test-file")) assert_kind_of Net::HTTPMethodNotAllowed, resp assert_equal "keep-alive", resp["Connection"] - resp = http.request(Net::HTTP::Mkcol.new("/dev666/test-dir")) + resp = http.request(new_req(:Mkcol, "/dev666/test-dir")) assert_kind_of Net::HTTPMethodNotAllowed, resp assert_equal "keep-alive", resp["Connection"] end diff --git a/test/test_helper.rb b/test/test_helper.rb index e28d863..0573964 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -46,3 +46,9 @@ def get_client(tries = 300, port = @port) end end while true end + +def new_req(meth, path) + r = Net::HTTP.const_get(meth).new(path) + r.content_type = "application/octet-stream" + r +end |