Skip to content

Commit b6f6de8

Browse files
committed
SDK-2771: Read from the error stream if we get >= 400 HTTP status code from auth service
1 parent 428ae21 commit b6f6de8

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

yoti-sdk-auth/src/main/java/com/yoti/auth/FormRequestClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ private static String encode(String v) {
5959
private byte[] parseResponse(HttpURLConnection httpUrlConnection) throws ResourceException, IOException {
6060
int responseCode = httpUrlConnection.getResponseCode();
6161
if (responseCode >= HttpURLConnection.HTTP_BAD_REQUEST) {
62-
byte[] responseBody = readBody(httpUrlConnection);
62+
byte[] responseBody = readBody(httpUrlConnection.getErrorStream());
6363
throw new ResourceException(responseCode, httpUrlConnection.getResponseMessage(), new String(responseBody));
6464
}
65-
return readBody(httpUrlConnection);
65+
return readBody(httpUrlConnection.getInputStream());
6666
}
6767

68-
private byte[] readBody(HttpURLConnection httpURLConnection) throws IOException {
69-
try (QuietCloseable<InputStream> inputStream = new QuietCloseable<>(httpURLConnection.getInputStream())) {
68+
private byte[] readBody(InputStream httpInputStream) throws IOException {
69+
try (QuietCloseable<InputStream> inputStream = new QuietCloseable<>(httpInputStream)) {
7070
return readChunked(inputStream.get());
7171
}
7272
}

0 commit comments

Comments
 (0)