@@ -285,7 +285,7 @@ def make_rdap_url( base_url, resource_path )
285
285
end
286
286
287
287
# Do an HTTP GET with the path.
288
- def get url , try
288
+ def get url , try , expect_rdap = true
289
289
290
290
data = @cache . get ( url )
291
291
if data == nil
@@ -310,7 +310,7 @@ def get url, try
310
310
if @config . config [ NicInfo ::SECURITY ] [ NicInfo ::TRY_INSECURE ]
311
311
@config . logger . mesg ( "Secure connection failed. Trying insecure connection." )
312
312
uri . scheme = "http"
313
- return get ( uri . to_s , try )
313
+ return get ( uri . to_s , try , expect_rdap )
314
314
else
315
315
raise e
316
316
end
@@ -319,19 +319,21 @@ def get url, try
319
319
case res
320
320
when Net ::HTTPSuccess
321
321
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
327
329
end
328
330
data = res . body
329
331
@cache . create_or_update ( url , data )
330
332
else
331
333
if res . code == "301" or res . code == "302" or res . code == "303" or res . code == "307" or res . code == "308"
332
334
res . error! if try >= 5
333
335
location = res [ "location" ]
334
- return get ( location , try + 1 )
336
+ return get ( location , try + 1 , expect_rdap )
335
337
end
336
338
res . error!
337
339
end #end case
@@ -426,7 +428,7 @@ def run
426
428
427
429
if @config . options . argv [ 0 ] == '.'
428
430
@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 )
430
432
json_data = JSON . load ( data )
431
433
432
434
if json_data [ "data" ] == nil || json_data [ "data" ] [ "ip" ] == nil
0 commit comments