@@ -285,7 +285,7 @@ def make_rdap_url( base_url, resource_path )
285285 end
286286
287287 # Do an HTTP GET with the path.
288- def get url , try
288+ def get url , try , expect_rdap = true
289289
290290 data = @cache . get ( url )
291291 if data == nil
@@ -310,7 +310,7 @@ def get url, try
310310 if @config . config [ NicInfo ::SECURITY ] [ NicInfo ::TRY_INSECURE ]
311311 @config . logger . mesg ( "Secure connection failed. Trying insecure connection." )
312312 uri . scheme = "http"
313- return get ( uri . to_s , try )
313+ return get ( uri . to_s , try , expect_rdap )
314314 else
315315 raise e
316316 end
@@ -319,19 +319,21 @@ def get url, try
319319 case res
320320 when Net ::HTTPSuccess
321321 content_type = res [ "content-type" ] . downcase
322- unless content_type . include? ( NicInfo ::RDAP_CONTENT_TYPE ) or content_type . include? ( NicInfo ::JSON_CONTENT_TYPE )
323- raise Net ::HTTPServerException . new ( "Bad Content Type" , res )
324- end
325- if content_type . include? NicInfo ::JSON_CONTENT_TYPE
326- @config . conf_msgs << "Server responded with non-RDAP content type but it is JSON"
322+ if expect_rdap
323+ unless content_type . include? ( NicInfo ::RDAP_CONTENT_TYPE ) or content_type . include? ( NicInfo ::JSON_CONTENT_TYPE )
324+ raise Net ::HTTPServerException . new ( "Bad Content Type" , res )
325+ end
326+ if content_type . include? NicInfo ::JSON_CONTENT_TYPE
327+ @config . conf_msgs << "Server responded with non-RDAP content type but it is JSON"
328+ end
327329 end
328330 data = res . body
329331 @cache . create_or_update ( url , data )
330332 else
331333 if res . code == "301" or res . code == "302" or res . code == "303" or res . code == "307" or res . code == "308"
332334 res . error! if try >= 5
333335 location = res [ "location" ]
334- return get ( location , try + 1 )
336+ return get ( location , try + 1 , expect_rdap )
335337 end
336338 res . error!
337339 end #end case
@@ -426,7 +428,7 @@ def run
426428
427429 if @config . options . argv [ 0 ] == '.'
428430 @config . logger . mesg ( "Obtaining current IP Address..." )
429- data = get ( "https://stat.ripe.net/data/whats-my-ip/data.json" , 0 )
431+ data = get ( "https://stat.ripe.net/data/whats-my-ip/data.json" , 0 , false )
430432 json_data = JSON . load ( data )
431433
432434 if json_data [ "data" ] == nil || json_data [ "data" ] [ "ip" ] == nil
0 commit comments