mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Adding MOVE request handling
This commit is contained in:
parent
94e5d4f396
commit
0474a613e1
4 changed files with 22 additions and 1 deletions
|
@ -429,6 +429,11 @@ module HTTParty
|
|||
perform_request Net::HTTP::Delete, path, options, &block
|
||||
end
|
||||
|
||||
# Perform a MOVE request to a path
|
||||
def move(path, options={}, &block)
|
||||
perform_request Net::HTTP::Move, path, options, &block
|
||||
end
|
||||
|
||||
# Perform a HEAD request to a path
|
||||
def head(path, options={}, &block)
|
||||
perform_request Net::HTTP::Head, path, options, &block
|
||||
|
@ -499,6 +504,10 @@ module HTTParty
|
|||
Basement.delete(*args, &block)
|
||||
end
|
||||
|
||||
def self.move(*args, &block)
|
||||
Basement.move(*args, &block)
|
||||
end
|
||||
|
||||
def self.head(*args, &block)
|
||||
Basement.head(*args, &block)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,8 @@ module HTTParty
|
|||
Net::HTTP::Put,
|
||||
Net::HTTP::Delete,
|
||||
Net::HTTP::Head,
|
||||
Net::HTTP::Options
|
||||
Net::HTTP::Options,
|
||||
Net::HTTP::Move
|
||||
]
|
||||
|
||||
SupportedURISchemes = [URI::HTTP, URI::HTTPS, URI::Generic]
|
||||
|
|
|
@ -358,6 +358,11 @@ describe HTTParty::Request do
|
|||
@request.perform.should == {"hash" => {"foo" => "bar"}}
|
||||
end
|
||||
|
||||
it "should be handled by MOVE transparently" do
|
||||
@request.http_method = Net::HTTP::Move
|
||||
@request.perform.should == {"hash" => {"foo" => "bar"}}
|
||||
end
|
||||
|
||||
it "should be handled by PATCH transparently" do
|
||||
@request.http_method = Net::HTTP::Patch
|
||||
@request.perform.should == {"hash" => {"foo" => "bar"}}
|
||||
|
|
|
@ -491,6 +491,12 @@ describe HTTParty do
|
|||
end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
|
||||
end
|
||||
|
||||
it "should fail with redirected MOVE" do
|
||||
lambda do
|
||||
@klass.move('/foo', :no_follow => true)
|
||||
end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
|
||||
end
|
||||
|
||||
it "should fail with redirected PUT" do
|
||||
lambda do
|
||||
@klass.put('/foo', :no_follow => true)
|
||||
|
|
Loading…
Reference in a new issue