CustomResponse.java
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.servlet.ServletOutputStream
* javax.servlet.ServletResponse
* org.apache.sling.api.SlingHttpServletResponse
* org.apache.sling.api.wrappers.SlingHttpServletResponseWrapper
*/
package com.adobe.forms.common.submitutils;
import com.adobe.forms.common.submitutils.CustomServletOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.wrappers.SlingHttpServletResponseWrapper;
public class CustomResponse
extends SlingHttpServletResponseWrapper {
private PrintWriter writer;
private CustomServletOutputStream outputStream;
public CustomResponse(SlingHttpServletResponse response) throws IOException {
super(response);
}
public ServletOutputStream getOutputStream() throws IOException {
if (this.outputStream == null) {
this.outputStream = new CustomServletOutputStream();
}
return this.outputStream;
}
public PrintWriter getWriter() throws IOException {
if (this.writer == null) {
this.writer = new PrintWriter(new OutputStreamWriter((OutputStream)this.getOutputStream(), this.getResponse().getCharacterEncoding()), true);
}
return this.writer;
}
public void flushBuffer() throws IOException {
if (this.writer != null) {
this.writer.flush();
} else if (this.outputStream != null) {
this.outputStream.flush();
}
}
public byte[] getCopy() {
if (this.outputStream != null) {
return this.outputStream.getCopy();
}
return new byte[0];
}
}