package io.wovn.wovnjava;

import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class WovnHttpServletResponse extends HttpServletResponseWrapper {
    public int status;

    protected Headers headers;
    protected ByteArrayOutputStream buff;
    protected PrintWriter writer;
    protected ServletOutputStream output;

    public WovnHttpServletResponse(HttpServletResponse response, Headers h) {
        super(response);
        this.headers = h;
        this.buff = new ByteArrayOutputStream();
    }

    public byte[] getData() {
        if (this.writer != null) {
            this.writer.close();
        }
        if (this.output != null) {
            try {
                this.output.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        byte[] ret = buff.toByteArray();

        this.buff = new ByteArrayOutputStream();
        this.output = null;
        this.writer = null;

        return ret;
    }

    public String toString() {
        return new String(this.getData());
    }

    public void setStatus(int sc) {
        status = sc;
        super.setStatus(sc);
    }

    public ServletOutputStream getOutputStream() throws IOException {
        if (this.output == null)
            this.output = new FilterServletOutputStream(this.buff);

        return this.output;
    }

    public PrintWriter getWriter() throws IOException {
        if (this.writer == null) {
            this.writer = new PrintWriter(
                    new OutputStreamWriter(this.getOutputStream(),this.getCharacterEncoding()),
                    true
            );
        }
        return this.writer;
    }
}

@@ -35,17 +35,128 @@
 java.io.
-*
+ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.OutputStreamWriter;%0Aimport java.io.PrintWriter
 ;%0A%0Aimpor
@@ -171,17 +171,35 @@
 servlet.
-*
+ServletOutputStream
 ;%0Aimport
@@ -222,19 +222,84 @@
 ttp.
-*;%0A%0Apublic 
+HttpServletResponse;%0Aimport javax.servlet.http.HttpServletResponseWrapper;%0A%0A
 clas
@@ -365,23 +365,16 @@
 r %7B%0A    
-public 
 int stat
@@ -384,23 +384,21 @@
 %0A%0A    pr
-otec
+iva
 te
-d
  Headers
@@ -413,23 +413,21 @@
 ;%0A    pr
-otec
+iva
 te
-d
  ByteArr
@@ -453,23 +453,21 @@
 ;%0A    pr
-otec
+iva
 te
-d
  PrintWr
@@ -489,15 +489,13 @@
   pr
-otec
+iva
 te
-d
  Ser
@@ -524,23 +524,16 @@
 t;%0A%0A    
-public 
 WovnHttp
@@ -703,21 +703,22 @@
 %7D%0A%0A    p
-ublic
+rivate
  byte%5B%5D 

Update WovnHttpServletResponse.java.