Friday, January 4, 2013

Java, Groovy, Android and the URL with underscore problem

lesson for today:

Groovy HTTPBuilder chokes on URLs where the hostname contains and underscore character.  For example  http://xx_host.name.domain.com.   Apparently the blame lies with the underlying java URL class which fails to parse due to the "illegal" underscore character.

What I find weird is how quietly folks seem to be accepting this limitation. Affects android as well.   Yes, strictly speaking underscores are not valid hostname characters,  but apparently that rule has been relaxed for subdomains and DNS configurations?    Either way from the various posts I've seen looks like underscores are here to stay and problems have been encountered with facebook, amazon aws and other big names.

If there's a workaround out there other than injecting the IP address instead of hostname  would love to hear about it.  I really, really hate it when my code is tied to a strict IP address.