From a29461057e54db60015bca4c4297949d071a7d9f Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 1 Feb 2022 12:09:55 +1100 Subject: [PATCH] fix up http issues? --- .../main/java/org/hl7/fhir/utilities/SimpleHTTPClient.java | 6 +++--- .../main/java/org/hl7/fhir/utilities/npm/PackageClient.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/SimpleHTTPClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/SimpleHTTPClient.java index e61de56b8..bb6b517b9 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/SimpleHTTPClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/SimpleHTTPClient.java @@ -147,7 +147,7 @@ public class SimpleHTTPClient { } } - return new HTTPResult(url, c.getResponseCode(), c.getRequestProperty("Content-Type"), TextFile.streamToBytes(c.getInputStream())); + return new HTTPResult(url, c.getResponseCode(), c.getRequestProperty("Content-Type"), TextFile.streamToBytes(c.getResponseCode() >= 400 ? c.getErrorStream() : c.getInputStream())); } private void setHeaders(HttpURLConnection c) { @@ -177,7 +177,7 @@ public class SimpleHTTPClient { setHeaders(c); c.getOutputStream().write(content); c.getOutputStream().close(); - return new HTTPResult(url, c.getResponseCode(), c.getRequestProperty("Content-Type"), TextFile.streamToBytes(c.getInputStream())); + return new HTTPResult(url, c.getResponseCode(), c.getRequestProperty("Content-Type"), TextFile.streamToBytes(c.getResponseCode() >= 400 ? c.getErrorStream() : c.getInputStream())); } @@ -194,7 +194,7 @@ public class SimpleHTTPClient { setHeaders(c); c.getOutputStream().write(content); c.getOutputStream().close(); - return new HTTPResult(url, c.getResponseCode(), c.getRequestProperty("Content-Type"), TextFile.streamToBytes(c.getInputStream())); + return new HTTPResult(url, c.getResponseCode(), c.getRequestProperty("Content-Type"), TextFile.streamToBytes(c.getResponseCode() >= 400 ? c.getErrorStream() : c.getInputStream())); } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java index 677cb6ca9..35f3788b5 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/PackageClient.java @@ -91,7 +91,7 @@ public class PackageClient { address)); } } - } catch (FileNotFoundException e) { + } catch (Exception e) { } return res; }