From ab70e53ac3b5102d4ecbe8f38d4f76afad29d37d Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 1 Jun 2010 12:30:52 +0000 Subject: * lib/net/http.rb: adding support to rfc5789 patch verb. Added a Net::HTTP::Patch class which expects a message body and response body. It recycles the post method into a patch one, that will send the encoded representation to the server. Summarizing, a new class has been created, the post method extracted into send_entity, including a new argument, which defines which class to use (Post or Patch) and finally a patch method was created. [ruby-core:30426] Patched by Guilherme Silveira git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/net/http/test_http.rb | 19 +++++++++++++++++++ test/net/http/utils.rb | 6 ++++++ 2 files changed, 25 insertions(+) (limited to 'test') diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 167eda933e..76280ad168 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -169,6 +169,25 @@ module TestNetHTTP_version_1_1_methods assert_equal ["a=x1", "a=x2", "b=y"], res.body.split(/[;&]/).sort end + def test_patch + start {|http| + _test_patch__base http + } + end + + def _test_patch__base(http) + uheader = {} + uheader['Accept'] = 'application/octet-stream' + data = 'patch data' + res, body = http.patch('/', data) + assert_kind_of Net::HTTPResponse, res + assert_kind_of String, body + assert_kind_of String, res.body + assert_equal data, body + assert_equal data, res.body + assert_equal data, res.entity + end + end diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb index 10c88d70d7..32cea2a78c 100644 --- a/test/net/http/utils.rb +++ b/test/net/http/utils.rb @@ -92,6 +92,12 @@ module TestNetHTTPUtils res.body = req.body res.chunked = @chunked end + + def do_PATCH(req, res) + res['Content-Type'] = req['Content-Type'] + res.body = req.body + res.chunked = @chunked + end end class NullWriter -- cgit v1.2.3