This is a limitation (I'd consider it to be a bug or at least a stupid feature) of HttpURLConnection. You're at least not the only one who encounters this when dealing with REST webservices using URLConnection.
Consider using Apache HttpComponents Client instead.