<p>I am trying to download an xml.gz file from a remote server with HttpsURLConnection in java, but I am getting an empty response.  Here is a sample of my code:</p>

<pre><code>URL server = new URL("https://www.myurl.com/path/sample_file.xml.gz");
HttpsURLConnection connection = (HttpsURLConnection)server.openConnection();
connection.connect();
</code></pre>

<p>When I try to get an InputStream from the connection, it is empty. (If I try connection.getInputStream().read() I get -1)  The file I am expecting is approximately 50MB. </p>

<p>To test my sanity, I aslo tried entering the exact same url in my browser, and it did return the file I needed. Am I missing something?  Do I have to set some sort of parameter in the connection?  Any help/direction is much appreciated.  </p>

Is any exception being logged? Is the website presenting a self-signed SSL certificate, or one that is not signed by a CA? There are several reasons why it might work fine in your browser (the browser might have been told to accept self-signed certs from that domain) and not in your code.
What are the results of using
curl
or
wget
to fetch the URL?
The fact that the InputStream is empty / result from the InputStream.read() == -1 implies that there is nothing in the stream to read, meaning that the stream was not able to even be set up properly.
Update
:
See this page
for some info on how you can deal with invalid/self-signed certificates in your connection code. Or, if the site is presenting a certificate but it is invalid, you can import it into the keystore of the server to tell Java to trust the certificate.
See this page for more info
.