HttpResponseWrapper.java
2.32 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.util.callbacks.Option
* javax.servlet.ServletOutputStream
* javax.servlet.http.HttpServletResponse
* javax.servlet.http.HttpServletResponseWrapper
*/
package com.adobe.cq.dam.s7imaging.impl.ps.access_log;
import com.adobe.cq.dam.s7imaging.impl.ps.access_log.ByteCountingServletOutputStream;
import com.scene7.is.util.callbacks.Option;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
public final class HttpResponseWrapper
extends HttpServletResponseWrapper {
private int status = 200;
private int contentLength = -1;
private Option<ByteCountingServletOutputStream> out = Option.none();
private Option<PrintWriter> writer = Option.none();
public HttpResponseWrapper(HttpServletResponse delegate) {
super(delegate);
}
public int getStatus() {
return this.status;
}
public long getContentWritten() throws IOException {
return this.out().count();
}
public int getContentLength() {
return this.contentLength;
}
public void setContentLength(int len) {
super.setContentLength(len);
this.contentLength = len;
}
public void setStatus(int sc, String sm) {
this.status = sc;
super.setStatus(sc, sm);
}
public void setStatus(int sc) {
this.status = sc;
super.setStatus(sc);
}
public ServletOutputStream getOutputStream() throws IOException {
return this.out();
}
public PrintWriter getWriter() throws IOException {
return this.writer();
}
private ByteCountingServletOutputStream out() throws IOException {
if (this.out.isEmpty()) {
this.out = Option.some((Object)((Object)new ByteCountingServletOutputStream(super.getOutputStream())));
}
return (ByteCountingServletOutputStream)((Object)this.out.get());
}
private PrintWriter writer() throws IOException {
if (this.writer.isEmpty()) {
this.writer = Option.some((Object)new PrintWriter((OutputStream)((Object)this.out())));
}
return (PrintWriter)this.writer.get();
}
}