From a5c44ca74bf747e1047ce9f3d5545b10b4cf7965 Mon Sep 17 00:00:00 2001 From: dozencrows Date: Sat, 10 May 2014 15:44:10 +0100 Subject: [PATCH] Status check now parses multiple lines in HTTP response --- .../me/malcolmlandon/motion/MotionCamera.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/uk/me/malcolmlandon/motion/MotionCamera.java b/src/uk/me/malcolmlandon/motion/MotionCamera.java index 5a72301..aac9e18 100644 --- a/src/uk/me/malcolmlandon/motion/MotionCamera.java +++ b/src/uk/me/malcolmlandon/motion/MotionCamera.java @@ -71,14 +71,23 @@ private String makeStatusRequest(HttpClient client, String statusUrl) throws IOE private String parseStatusResponse(HttpResponse response) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); - String line = reader.readLine(); - if (line.contains("PAUSE")) { - return "Motion Status: PAUSED"; - } else if (line.contains("ACTIVE")) { - return "Motion Status: ACTIVE"; - } else { - return "Motion status UNKNOWN. Response Body: " + line; - } + StringBuilder content = new StringBuilder(); + String line; + + do { + line = reader.readLine(); + if (line != null) { + if (line.contains("PAUSE")) { + return "Motion Status: PAUSED"; + } else if (line.contains("ACTIVE")) { + return "Motion Status: ACTIVE"; + } else { + content.append(line); + } + } + } while (line != null); + + return "Motion status UNKNOWN. Response Body: " + content.toString(); } public String startDetection() {