Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Http~URLConnection response code -1
    primarykey
    data
    text
    <p>Trying to download a file in Java from a Http server (nginx)</p> <p>The exact same link java is attempting to download works in the browser and downloads, but java responds with:</p> <pre><code>java.io.IOException: &lt;URL WOULD BE HERE&gt; returned response code -1 at com.atlauncher.data.Downloadable.getConnection(Downloadable.java:149) at com.atlauncher.data.Downloadable.getFilesize(Downloadable.java:85) at com.atlauncher.workers.InstanceInstaller.configurePack(InstanceInstaller.java:1134) at com.atlauncher.workers.InstanceInstaller.doInBackground(InstanceInstaller.java:1399) at com.atlauncher.workers.InstanceInstaller.doInBackground(InstanceInstaller.java:59) at javax.swing.SwingWorker$1.call(SwingWorker.java:296) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at javax.swing.SwingWorker.run(SwingWorker.java:335) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) </code></pre> <p>The download code:</p> <pre><code>this.connection = (HttpURLConnection) new URL(this.url).openConnection(); this.connection.setUseCaches(false); this.connection.setDefaultUseCaches(false); this.connection.setConnectTimeout(9000); //this.connection.setRequestProperty("Accept-Encoding", "gzip"); this.connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"); this.connection.setRequestProperty("Cache-Control", "no-store,max-age=0,no-cache"); this.connection.setRequestProperty("Expires", "0"); this.connection.setRequestProperty("Pragma", "no-cache"); this.connection.connect(); if (this.connection.getResponseCode() / 100 != 2) { System.out.println(this.connection); throw new IOException(this.url + " returned response code " + this.connection.getResponseCode()); } </code></pre> <p>Any ideas why this is occurring? It's strange that the exact same url works in the browser. And the exact same code works downloading different files from the same server, and directory...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload