Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

In case of thin server the client should concatenate all responses (c…

…loses #259).
  • Loading branch information...
commit fe8424e0626058b02bad02fca2562984059ae6c3 1 parent e492573
@weppos authored
View
4 CHANGELOG.rdoc
@@ -3,7 +3,9 @@
== next maintenance
-* FIXED: rake coverage task crashes.
+* FIXED: 'rake coverage' task crashes.
+
+* FIXED: In case of thin server the client should concatenate all responses (closes #259).
* ADDED: Whois binary (closes #271).
View
19 lib/whois/server/adapters/afilias.rb
@@ -17,18 +17,27 @@
module Whois
class Server
module Adapters
-
+
class Afilias < Base
-
+
def request(qstring)
response = ask_the_socket(qstring, "whois.afilias-grs.info", DEFAULT_WHOIS_PORT)
- if response =~ /Domain Name:/ && response =~ /Whois Server:(\S+)/
- ask_the_socket(qstring, $1, DEFAULT_WHOIS_PORT)
+ endpoint = extract_referral(response)
+ if endpoint
+ response + "\n" + ask_the_socket(qstring, endpoint, DEFAULT_WHOIS_PORT)
else
response
end
end
-
+
+ private
+
+ def extract_referral(response)
+ if response =~ /Domain Name:/ && response =~ /Whois Server:(\S+)/
+ $1
+ end
+ end
+
end
end
View
23 lib/whois/server/adapters/pir.rb
@@ -17,21 +17,30 @@
module Whois
class Server
module Adapters
-
+
class Pir < Base
-
+
def request(qstring)
response = ask_the_socket("FULL #{qstring}", "whois.publicinterestregistry.net", DEFAULT_WHOIS_PORT)
- if response =~ /Registrant Name:SEE SPONSORING REGISTRAR/ &&
- response =~ /Registrant Street1:Whois Server:(\S+)/
- ask_the_socket(qstring, $1, DEFAULT_WHOIS_PORT)
+ endpoint = extract_referral(response)
+ if endpoint
+ response + "\n" + ask_the_socket(qstring, endpoint, DEFAULT_WHOIS_PORT)
else
response
end
end
-
+
+ private
+
+ def extract_referral(response)
+ if response =~ /Registrant Name:SEE SPONSORING REGISTRAR/ &&
+ response =~ /Registrant Street1:Whois Server:(\S+)/
+ $1
+ end
+ end
+
end
-
+
end
end
end
View
17 lib/whois/server/adapters/verisign.rb
@@ -22,15 +22,24 @@ class Verisign < Base
def request(qstring)
response = ask_the_socket("=#{qstring}", host, DEFAULT_WHOIS_PORT)
- if response =~ /Domain Name:/ && response =~ /Whois Server: (\S+)/
- ask_the_socket(qstring, $1, DEFAULT_WHOIS_PORT)
+ endpoint = extract_referral(response)
+ if endpoint
+ response + "\n" + ask_the_socket(qstring, endpoint, DEFAULT_WHOIS_PORT)
else
response
end
end
-
+
+ private
+
+ def extract_referral(response)
+ if response =~ /Domain Name:/ && response =~ /Whois Server: (\S+)/
+ $1
+ end
+ end
+
end
-
+
end
end
end
View
14 test/adapters/afilias_test.rb
@@ -10,16 +10,18 @@ def setup
end
def test_query
- expected = "No match for DOMAIN.FOO."
- @server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(expected)
+ response = "No match for DOMAIN.FOO."
+ expected = response
+ @server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(response)
assert_equal expected, @server.query("domain.foo")
end
def test_query_with_referral
- response = File.read(File.dirname(__FILE__) + "/../testcases/referrals/afilias.bz.txt")
- expected = "Match for DOMAIN.FOO."
- @server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(response)
- @server.expects(:ask_the_socket).with("domain.foo", "whois.belizenic.bz", 43).returns(expected)
+ referral = File.read(File.dirname(__FILE__) + "/../testcases/referrals/afilias.bz.txt")
+ response = "Match for DOMAIN.FOO."
+ expected = referral + "\n" + response
+ @server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(referral)
+ @server.expects(:ask_the_socket).with("domain.foo", "whois.belizenic.bz", 43).returns(response)
assert_equal expected, @server.query("domain.foo")
end
View
14 test/adapters/pir_test.rb
@@ -10,16 +10,18 @@ def setup
end
def test_query
- expected = "No match for DOMAIN.FOO."
- @server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(expected)
+ response = "No match for DOMAIN.FOO."
+ expected = response
+ @server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(response)
assert_equal expected, @server.query("domain.foo")
end
def test_query_with_referral
- response = File.read(File.dirname(__FILE__) + "/../testcases/referrals/pir.org.txt")
- expected = "Match for DOMAIN.FOO."
- @server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(response)
- @server.expects(:ask_the_socket).with("domain.foo", "whois.iana.org", 43).returns(expected)
+ referral = File.read(File.dirname(__FILE__) + "/../testcases/referrals/pir.org.txt")
+ response = "Match for DOMAIN.FOO."
+ expected = referral + "\n" + response
+ @server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(referral)
+ @server.expects(:ask_the_socket).with("domain.foo", "whois.iana.org", 43).returns(response)
assert_equal expected, @server.query("domain.foo")
end
View
14 test/adapters/verisign_test.rb
@@ -10,16 +10,18 @@ def setup
end
def test_query
- expected = "No match for DOMAIN.FOO."
- @server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(expected)
+ response = "No match for DOMAIN.FOO."
+ expected = response
+ @server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(response)
assert_equal expected, @server.query("domain.foo")
end
def test_query_with_referral
- response = File.read(File.dirname(__FILE__) + "/../testcases/referrals/crsnic.com.txt")
- expected = "Match for DOMAIN.FOO."
- @server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(response)
- @server.expects(:ask_the_socket).with("domain.foo", "whois.tucows.com", 43).returns(expected)
+ referral = File.read(File.dirname(__FILE__) + "/../testcases/referrals/crsnic.com.txt")
+ response = "Match for DOMAIN.FOO."
+ expected = referral + "\n" + response
+ @server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(referral)
+ @server.expects(:ask_the_socket).with("domain.foo", "whois.tucows.com", 43).returns(response)
assert_equal expected, @server.query("domain.foo")
end
Please sign in to comment.
Something went wrong with that request. Please try again.