Skip to content

Commit 4d1aab2

Browse files
authored
Merge pull request #137 from raphaeladrien/handling-payload-bigger-than-10KB
Refactor request.rb to handling HTTP 413
2 parents 86e613f + d62aa85 commit 4d1aab2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/pusher/request.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def handle_response(status_code, body)
9494
raise Error, "404 Not found (#{@uri.path})"
9595
when 407
9696
raise Error, "Proxy Authentication Required"
97+
when 413
98+
raise Error, "Payload Too Large > 10KB"
9799
else
98100
raise Error, "Unknown error (status code #{status_code}): #{body}"
99101
end

spec/client_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@
430430
expect { call_api }.to raise_error(Pusher::Error, 'Proxy Authentication Required')
431431
end
432432

433+
it "should raise Pusher::Error if pusher returns 413" do
434+
stub_request(verb, @url_regexp).to_return({:status => 413})
435+
expect { call_api }.to raise_error(Pusher::Error, 'Payload Too Large > 10KB')
436+
end
437+
433438
it "should raise Pusher::Error if pusher returns 500" do
434439
stub_request(verb, @url_regexp).to_return({:status => 500, :body => "some error"})
435440
expect { call_api }.to raise_error(Pusher::Error, 'Unknown error (status code 500): some error')

0 commit comments

Comments
 (0)