aboutsummaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@verizonmedia.com>2021-09-09 18:56:34 +0200
committerValerij Fredriksen <valerijf@verizonmedia.com>2021-09-09 21:41:11 +0200
commit2acd3ea90f5deeff9714ec556fba610f6b0e130c (patch)
tree623cbdbb4a5bc7de406467a078886104fea1c1a1 /container-core
parent381fa00f92922e011442a1ac8510986d4a5f0f64 (diff)
Use byte[] instead
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/restapi/ByteArrayResponse.java26
-rw-r--r--container-core/src/main/java/com/yahoo/restapi/StringResponse.java18
2 files changed, 28 insertions, 16 deletions
diff --git a/container-core/src/main/java/com/yahoo/restapi/ByteArrayResponse.java b/container-core/src/main/java/com/yahoo/restapi/ByteArrayResponse.java
new file mode 100644
index 00000000000..1299a2c6eb4
--- /dev/null
+++ b/container-core/src/main/java/com/yahoo/restapi/ByteArrayResponse.java
@@ -0,0 +1,26 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.restapi;
+
+import com.yahoo.container.jdisc.HttpResponse;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author freva
+ */
+public class ByteArrayResponse extends HttpResponse {
+
+ private final byte[] data;
+
+ public ByteArrayResponse(byte[] data) {
+ super(200);
+ this.data = data;
+ }
+
+ @Override
+ public void render(OutputStream stream) throws IOException {
+ stream.write(data);
+ }
+
+}
diff --git a/container-core/src/main/java/com/yahoo/restapi/StringResponse.java b/container-core/src/main/java/com/yahoo/restapi/StringResponse.java
index 55ea22880de..003b58de827 100644
--- a/container-core/src/main/java/com/yahoo/restapi/StringResponse.java
+++ b/container-core/src/main/java/com/yahoo/restapi/StringResponse.java
@@ -1,27 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.restapi;
-import com.yahoo.container.jdisc.HttpResponse;
-
-import java.io.IOException;
-import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
/**
* @author bratseth
*/
-public class StringResponse extends HttpResponse {
-
- private final String message;
-
+public class StringResponse extends ByteArrayResponse {
public StringResponse(String message) {
- super(200);
- this.message = message;
+ super(message.getBytes(StandardCharsets.UTF_8));
}
-
- @Override
- public void render(OutputStream stream) throws IOException {
- stream.write(message.getBytes(StandardCharsets.UTF_8));
- }
-
}