1 package dolda.jsvc.util;
7 public abstract class ResponseBuffer implements Request {
8 private boolean flushed = false;
9 private int respcode = -1;
10 private String resptext = null;
11 private OutputStream out = null, wrapout = null;
12 private MultiMap<String, String> headers = new HeaderTreeMap() {
13 protected void modified() {
18 private void ckflush() {
20 throw(new IllegalStateException("Response has been flushed; header information cannot be modified"));
23 private void flush() {
35 private class FlushStream extends OutputStream {
36 private FlushStream() {
39 public void flush() throws IOException {
40 ResponseBuffer.this.flush();
44 public void close() throws IOException {
49 public void write(int b) throws IOException {
50 ResponseBuffer.this.flush();
54 public void write(byte[] b) throws IOException {
55 write(b, 0, b.length);
58 public void write(byte[] b, int off, int len) throws IOException {
59 ResponseBuffer.this.flush();
60 out.write(b, off, len);
64 public OutputStream output() {
66 wrapout = new BufferedOutputStream(new FlushStream(), 16384);
70 public void status(int code) {
71 status(code, Misc.statustext(code));
74 public void status(int code, String text) {
80 public MultiMap<String, String> outheaders() {
84 protected abstract void backflush();
85 protected abstract OutputStream realoutput();