Skip to content

Commit 06d9813

Browse files
committed
Treat QUERY requests as idempotent
1 parent ed5aad7 commit 06d9813

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎lib/protocol/http/request.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def self.[](method, path = nil, _headers = nil, _body = nil, scheme: nil, author
134134

135135
# Whether the request can be replayed without side-effects.
136136
def idempotent?
137+
return true if @method == Methods::QUERY
138+
137139
@method != Methods::POST && (@body.nil? || @body.empty?)
138140
end
139141

‎test/protocol/http/request.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@
128128
expect(request).to be(:idempotent?)
129129
end
130130

131+
with "QUERY request with a body" do
132+
let(:request) {subject["QUERY", "/search", body: "term=ruby"]}
133+
134+
it "should be idempotent" do
135+
expect(request).to be(:idempotent?)
136+
end
137+
end
138+
131139
it "should have a string representation" do
132140
expect(request.to_s).to be == "http://localhost: GET /index.html HTTP/1.0"
133141
end

0 commit comments

Comments
 (0)