public void write(OutputStream outputStream) {
        StringBuilder sb = new StringBuilder();
        // add response code
        sb.append(headers.get(ResponseKeys.PROTOCOL.getValue()).getValue());
        sb.append(" ");
        sb.append(status.getStatus());
        sb.append(" ");
        sb.append(status.getMessage());
        sb.append("\n");


        // add date
        sb.append("Date: ");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy  HH:mm:ss z");
        sb.append(simpleDateFormat.format(new Date()));
        sb.append("\n");

        // set cookie
        sb.append(getSession().toCookie());

        // add all the headers
        for (Param<String, Object> param : headers.getParamList()) {
            sb.append(param.getKey());
            sb.append(": ");
            sb.append(param.getValue());
            sb.append("\n");
        }

        // end headers
        sb.append("\r\n");

        // add contentChar if not add content
        if (contentChar != null) {
            try {
                // write the headers
                try {
                    outputStream.write(sb.toString().getBytes("UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    outputStream.write(sb.toString().getBytes());
                }

                //write the file content
                outputStream.write(getContentChar());

                // write the delimiters
                outputStream.write("\n\r\n\r".getBytes());

            } catch (Exception e) {
                e.printStackTrace();
            }

        } else {

            // append the content
            sb.append(getContent());

            // append the delimiters
            sb.append("\n\r\n\r");

            // write content to output stream
            try {
                try {
                    outputStream.write(sb.toString().getBytes("UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    outputStream.write(sb.toString().getBytes());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    }