Skip to content

Commit

Permalink
refactor to use constants
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Aug 14, 2023
1 parent abcb2b9 commit 42ecb61
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/io/cryostat/agent/remote/RecordingsContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,18 @@ private void handleGetRecording(HttpExchange exchange, long id) {
BufferedInputStream bis = new BufferedInputStream(stream);
OutputStream response = exchange.getResponseBody()) {
if (stream == null) {
exchange.sendResponseHeaders(HttpStatus.SC_NO_CONTENT, -1);
exchange.sendResponseHeaders(
HttpStatus.SC_NO_CONTENT, BODY_LENGTH_NONE);
} else {
exchange.sendResponseHeaders(HttpStatus.SC_OK, 0);
exchange.sendResponseHeaders(
HttpStatus.SC_OK, BODY_LENGTH_UNKNOWN);
bis.transferTo(response);
}
} catch (IOException ioe) {
log.error("I/O error", ioe);
try {
exchange.sendResponseHeaders(
HttpStatus.SC_INTERNAL_SERVER_ERROR, -1);
HttpStatus.SC_INTERNAL_SERVER_ERROR, BODY_LENGTH_NONE);
} catch (IOException ioe2) {
log.error("Failed to write response", ioe2);
}
Expand All @@ -183,7 +185,8 @@ private void handleGetRecording(HttpExchange exchange, long id) {
},
() -> {
try {
exchange.sendResponseHeaders(HttpStatus.SC_NOT_FOUND, -1);
exchange.sendResponseHeaders(
HttpStatus.SC_NOT_FOUND, BODY_LENGTH_NONE);
} catch (IOException e) {
log.error("Failed to write response", e);
}
Expand Down

0 comments on commit 42ecb61

Please sign in to comment.