Mercurial Hosting > luan
annotate src/goodjava/webserver/ResponseOutputStream.java @ 2019:cbc5a66217d7
windows fix
| author | Franklin Schmidt <fschmidt@gmail.com> | 
|---|---|
| date | Fri, 03 Oct 2025 18:28:21 -0600 | 
| parents | bba3e529e346 | 
| children | 
| rev | line source | 
|---|---|
| 1402 
27efb1fcbcb5
move luan.lib to goodjava
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1347diff
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 } | 
