Mercurial Hosting > luan
annotate src/goodjava/webserver/ResponseOutputStream.java @ 2008:bba3e529e346 default tip
chunked encoding
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 27 Aug 2025 01:14:17 -0600 |
parents | 27efb1fcbcb5 |
children |
rev | line source |
---|---|
1402
27efb1fcbcb5
move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents:
1347
diff
changeset
|
1 package goodjava.webserver; |
1137 | 2 |
3 import java.io.ByteArrayOutputStream; | |
4 import java.io.ByteArrayInputStream; | |
5 import java.io.IOException; | |
6 | |
7 | |
8 public class ResponseOutputStream extends ByteArrayOutputStream { | |
9 private final Response response; | |
10 | |
11 public ResponseOutputStream(Response response) { | |
1160 | 12 if(response==null) throw new NullPointerException(); |
1137 | 13 this.response = response; |
14 } | |
15 | |
16 @Override public void close() throws IOException { | |
17 super.close(); | |
18 int size = size(); | |
2008 | 19 response.headers.put("Content-Length",Long.toString(size)); |
20 response.body = new ByteArrayInputStream(buf,0,size); | |
1137 | 21 } |
22 } |