GET URL that pretends to crash (500)
Generating 500 INTERNAL SERVER ERROR will be more fun, but we don't have to do anything special. Just send a GET request to the /status/500 end-point.
examples/net-http/get_response_get_httpbin_500.rb
require 'net/http' url = 'https://httpbin.org/status/500' uri = URI(url) # puts(uri) response = Net::HTTP.get_response(uri) if response.is_a?(Net::HTTPSuccess) #puts "Headers:" #puts response.to_hash.inspect #puts '------' puts response.body else puts response.code puts response.msg end
The output was:
500 INTERNAL SERVER ERROR