1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.web.includeservletasstring; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.io.OutputStreamWriter; |
24 |
|
import java.io.PrintWriter; |
25 |
|
|
26 |
|
import javax.servlet.ServletOutputStream; |
27 |
|
import javax.servlet.http.HttpServletResponse; |
28 |
|
import javax.servlet.http.HttpServletResponseWrapper; |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 7 |
Complexity Density: 0.58 |
|
30 |
|
public class BufferedResponse extends HttpServletResponseWrapper |
31 |
|
{ |
32 |
|
protected HttpServletResponse internalResponse; |
33 |
|
|
34 |
|
protected BufferOutputStream outputStream; |
35 |
|
|
36 |
|
protected PrintWriter writer; |
37 |
|
|
38 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
39 |
0 |
public BufferedResponse(HttpServletResponse internalResponse)... |
40 |
|
{ |
41 |
0 |
super(internalResponse); |
42 |
|
|
43 |
0 |
this.internalResponse = internalResponse; |
44 |
|
} |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
46 |
0 |
@Override... |
47 |
|
public ServletOutputStream getOutputStream() throws IOException |
48 |
|
{ |
49 |
0 |
if (this.outputStream == null) { |
50 |
0 |
this.outputStream = new BufferOutputStream(); |
51 |
|
} |
52 |
|
|
53 |
0 |
return this.outputStream; |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
56 |
0 |
@Override... |
57 |
|
public PrintWriter getWriter() throws IOException |
58 |
|
{ |
59 |
0 |
if (this.writer == null) { |
60 |
0 |
this.writer = new PrintWriter(new OutputStreamWriter(getOutputStream(), getCharacterEncoding())); |
61 |
|
} |
62 |
|
|
63 |
0 |
return this.writer; |
64 |
|
} |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
66 |
0 |
public byte[] getBufferAsByteArray() throws IOException... |
67 |
|
{ |
68 |
0 |
if (this.writer != null) { |
69 |
0 |
this.writer.flush(); |
70 |
|
} |
71 |
|
|
72 |
0 |
this.outputStream.flush(); |
73 |
|
|
74 |
0 |
return this.outputStream.getContentsAsByteArray(); |
75 |
|
} |
76 |
|
|
77 |
|
} |