Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for lock and unlock http requests #596

Merged
merged 2 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pkg/
.rvmrc
coverage
*.gem
.idea
8 changes: 8 additions & 0 deletions lib/httparty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ def mkcol(path, options = {}, &block)
perform_request Net::HTTP::Mkcol, path, options, &block
end

def lock(path, options = {}, &block)
perform_request Net::HTTP::Lock, path, options, &block
end

def unlock(path, options = {}, &block)
perform_request Net::HTTP::Unlock, path, options, &block
end

attr_reader :default_options

private
Expand Down
2 changes: 2 additions & 0 deletions lib/httparty/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Request #:nodoc:
Net::HTTP::Move,
Net::HTTP::Copy,
Net::HTTP::Mkcol,
Net::HTTP::Lock,
Net::HTTP::Unlock,
]

SupportedURISchemes = ['http', 'https', 'webcal', nil]
Expand Down
2 changes: 1 addition & 1 deletion lib/httparty/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module HTTParty
VERSION = "0.16.2"
VERSION = "0.16.3"
end
42 changes: 42 additions & 0 deletions spec/httparty/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,16 @@
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should be handled by LOCK transparently" do
@request.http_method = Net::HTTP::Lock
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should be handled by UNLOCK transparently" do
@request.http_method = Net::HTTP::Unlock
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should keep track of cookies between redirects" do
@redirect['Set-Cookie'] = 'foo=bar; name=value; HTTPOnly'
@request.perform
Expand Down Expand Up @@ -914,6 +924,16 @@
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should be handled by LOCK transparently" do
@request.http_method = Net::HTTP::Lock
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should be handled by UNLOCK transparently" do
@request.http_method = Net::HTTP::Unlock
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should keep track of cookies between redirects" do
@redirect['Set-Cookie'] = 'foo=bar; name=value; HTTPOnly'
@request.perform
Expand Down Expand Up @@ -1052,6 +1072,16 @@
expect(@request.perform.code).to eq(304)
end

it "should be handled by LOCK transparently" do
@request.http_method = Net::HTTP::Lock
expect(@request.perform.code).to eq(304)
end

it "should be handled by UNLOCK transparently" do
@request.http_method = Net::HTTP::Unlock
expect(@request.perform.code).to eq(304)
end

it 'should not log the redirection' do
logger_double = double
expect(logger_double).to receive(:info).once
Expand Down Expand Up @@ -1123,6 +1153,18 @@
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should be handled by LOCK transparently" do
@request.http_method = Net::HTTP::Lock
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end

it "should be handled by UNLOCK transparently" do
@request.http_method = Net::HTTP::Unlock
expect(@request.perform.parsed_response).to eq({"hash" => {"foo" => "bar"}})
end



it "should keep track of cookies between redirects" do
@redirect['Set-Cookie'] = 'foo=bar; name=value; HTTPOnly'
@request.perform
Expand Down