Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding -r argument to executable to fail if response code >= 400

Failing if the response code is >= 400 is very helpful in for example
continuous integration to check after deployment that certain pages still
work.
  • Loading branch information...
commit d0a88d79b4c0a9c05181ff3f876a79b957a52691 1 parent 8fe9fda
@flomotlik flomotlik authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 bin/httparty
View
5 bin/httparty
@@ -54,6 +54,10 @@ OptionParser.new do |o|
opts[:basic_auth] = { :username => user, :password => password }
end
+ o.on("-r", "--response-code", "Command fails if response code >= 400") do
+ opts[:response_code] = true
+ end
+
o.on("-h", "--help", "Show help documentation") do |h|
puts o
exit
@@ -106,3 +110,4 @@ else
puts response
end
end
+exit false if opts[:response_code] && response.code >= 400
Please sign in to comment.
Something went wrong with that request. Please try again.