fix up http issues?

This commit is contained in:
Grahame Grieve 2022-02-01 12:09:55 +11:00
parent 96538ba249
commit a29461057e
2 changed files with 4 additions and 4 deletions

View File

@ -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()));
}

View File

@ -91,7 +91,7 @@ public class PackageClient {
address));
}
}
} catch (FileNotFoundException e) {
} catch (Exception e) {
}
return res;
}