private void sendResponse(String status, String mime, Properties header, InputStream data) {
        try {
            if (status == null)
                throw new Error("sendResponse(): Status can't be null.");
            OutputStream out = socket.getOutputStream();
            PrintWriter pw = new PrintWriter(out);
            pw.print("HTTP/1.0 " + status + " \r\n");

            if (mime != null)
                pw.print("Content-Type: " + mime + "\r\n");

            if (header == null || header.getProperty("Date") == null)
                pw.print("Date: " + DateUtils.formatYMD_HMS(new Date()) + "\r\n");

            if (header != null) {
                Enumeration e = header.keys();
                while (e.hasMoreElements()) {
                    String key = (String) e.nextElement();
                    String value = header.getProperty(key);
                    pw.print(key + ": " + value + "\r\n");
                }
            }

            pw.print("\r\n");
            pw.flush();

            if (data != null) {
                byte[] buff = new byte[2048];
                while (true) {
                    int read = data.read(buff, 0, 2048);
                    if (read <= 0)
                        break;
                    out.write(buff, 0, read);
                }
            }
            out.flush();
            out.close();
            if (data != null)
                data.close();
        } catch (IOException ioe) {
            try {
                socket.close();
            } catch (Throwable ignored) {
            }
        }
    }
@author Robert HG (254963746@qq.com)  on 2/17/16.
lts-core/src/main/java/com/github/ltsopensource/cmd/HttpCmdExecutor.java