-
Bug
-
Resolution: Incomplete
-
P4
-
None
-
21, 25
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Linux:
21.0.3.0.9-1-jdk
Windows:
openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment (Red_Hat-21.0.4.0+7-1) (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.4.0+7-1) (build 21.0.4+7-LTS, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Downloading the url (file)
https://www.treasury.gov/ofac/downloads/sdn.xml
which redirects to other urls (checked with wget) thows the above mentioned IOException.
Using URL-connection works.
If using the first redirect with HttpClient
https://sanctionslistservice.ofac.treas.gov/api/publicationpreview/exports/sdn.xml
the download works.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
try (HttpClient hc =
HttpClient.newBuilder().followRedirects(Redirect.NORMAL).build();) {
System.out.println("httpclient - start");
final HttpResponse<byte[]> res = hc.send(
HttpRequest.newBuilder("https://www.treasury.gov/ofac/downloads/sdn.xml").build(), BodyHandlers.ofByteArray());
System.out.println("httpclient - statuscode: " + res.statusCode());
System.out.println("httpclient - received " + res.body().length + " bytes");
} catch (IOException | InterruptedException e) {
e.printStackTrace(System.out);
}
System.out.println("httpclient - end");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should download the file.
ACTUAL -
IOException
---------- BEGIN SOURCE ----------
see Steps to Reproduce
---------- END SOURCE ----------
Linux:
21.0.3.0.9-1-jdk
Windows:
openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment (Red_Hat-21.0.4.0+7-1) (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.4.0+7-1) (build 21.0.4+7-LTS, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Downloading the url (file)
https://www.treasury.gov/ofac/downloads/sdn.xml
which redirects to other urls (checked with wget) thows the above mentioned IOException.
Using URL-connection works.
If using the first redirect with HttpClient
https://sanctionslistservice.ofac.treas.gov/api/publicationpreview/exports/sdn.xml
the download works.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
try (HttpClient hc =
HttpClient.newBuilder().followRedirects(Redirect.NORMAL).build();) {
System.out.println("httpclient - start");
final HttpResponse<byte[]> res = hc.send(
HttpRequest.newBuilder("https://www.treasury.gov/ofac/downloads/sdn.xml").build(), BodyHandlers.ofByteArray());
System.out.println("httpclient - statuscode: " + res.statusCode());
System.out.println("httpclient - received " + res.body().length + " bytes");
} catch (IOException | InterruptedException e) {
e.printStackTrace(System.out);
}
System.out.println("httpclient - end");
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should download the file.
ACTUAL -
IOException
---------- BEGIN SOURCE ----------
see Steps to Reproduce
---------- END SOURCE ----------