Mercurial Hosting > luan
annotate src/goodjava/webserver/ResponseOutputStream.java @ 2010:f45ed55f5c11 default tip
fix chunked encoding
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 02 Sep 2025 06:00:41 -0600 |
parents | bba3e529e346 |
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 } |