正在从RESTAPI响应下载数据,但得到的响应代码为-1

正在从RESTAPI响应下载数据,但得到的响应代码为-1,rest,https,httpresponse,Rest,Https,Httpresponse,文档中的REST API详细信息: GET /REST/sql_snapshot/2003-03-01.sql.gz HTTP/1.1 Host: some.api.net Authorization: Basic qpow3i12o3 The response shown below omits the message body, which contains binary compressed SQL data. HTTP/1.1 200 OK Date: Wed, 05 Mar 200

文档中的REST API详细信息:

GET /REST/sql_snapshot/2003-03-01.sql.gz HTTP/1.1
Host: some.api.net
Authorization: Basic qpow3i12o3

The response shown below omits the message body, which contains binary compressed SQL data.

HTTP/1.1 200 OK
Date: Wed, 05 Mar 2003 10:19:46 GMT
Server: Apache/1.3.22 (Unix)  (Red-Hat/Linux)Content-Type: application/octet-stream
我从下面得到一个响应代码-1

URL url = new URL("https://some.api.net/REST/sql_snapshot/2003-03-01.sql.gz");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Content-Type", "application/octet-stream");
connection.setDoOutput(true);
connection.connect();