From 36aa8639fd2ed49e04a2047598a7a3ac96ff8206 Mon Sep 17 00:00:00 2001 From: Rahul Rudragoudar Date: Mon, 17 Dec 2018 13:38:31 +0530 Subject: [PATCH] Added binary data support for response class --- src/main/java/HTTPServer.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/HTTPServer.java b/src/main/java/HTTPServer.java index a571b5b..de185e3 100644 --- a/src/main/java/HTTPServer.java +++ b/src/main/java/HTTPServer.java @@ -1793,6 +1793,17 @@ public class HTTPServer { out.write(content); } + public void send(int status, byte[] text) throws IOException { + //byte[] content = text.getBytes("UTF-8"); + byte[] content = text; + sendHeaders(status, content.length, -1, + "W/\"" + Integer.toHexString(text.hashCode()) + "\"", + "text/html; charset=utf-8", null); + OutputStream out = getBody(); + if (out != null) + out.write(content); + } + /** * Sends an error response with the given status and detailed message. * An HTML body is created containing the status and its description,