summaryrefslogtreecommitdiffstats
path: root/configserver/src/main/java/com/yahoo/vespa/config/server/http/ProxyResponse.java
diff options
context:
space:
mode:
Diffstat (limited to 'configserver/src/main/java/com/yahoo/vespa/config/server/http/ProxyResponse.java')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/ProxyResponse.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ProxyResponse.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ProxyResponse.java
new file mode 100644
index 00000000000..114c6c08bb6
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ProxyResponse.java
@@ -0,0 +1,37 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config.server.http;
+
+import com.yahoo.container.jdisc.HttpResponse;
+import org.apache.commons.io.IOUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class ProxyResponse extends HttpResponse {
+ private final String contentType;
+ private final InputStream inputStream;
+
+ /**
+ *
+ * @param status
+ * @param contentType
+ * @param inputStream Ownership is passed to ProxyResponse (responsible for closing it)
+ */
+ public ProxyResponse(int status, String contentType, InputStream inputStream) {
+ super(status);
+ this.contentType = contentType;
+ this.inputStream = inputStream;
+ }
+
+ @Override
+ public void render(OutputStream outputStream) throws IOException {
+ IOUtils.copy(inputStream, outputStream);
+ inputStream.close();
+ }
+
+ @Override
+ public String getContentType() {
+ return contentType;
+ }
+}