Mercurial Hosting > luan
annotate src/goodjava/webserver/ResponseOutputStream.java @ 1402:27efb1fcbcb5
move luan.lib to goodjava
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 17 Sep 2019 01:35:01 -0400 |
| parents | src/luan/lib/webserver/ResponseOutputStream.java@643cf1c37723 |
| children | bba3e529e346 |
| 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 // plenty of room for improvement | |
| 9 public class ResponseOutputStream extends ByteArrayOutputStream { | |
| 10 private final Response response; | |
| 11 | |
| 12 public ResponseOutputStream(Response response) { | |
| 1160 | 13 if(response==null) throw new NullPointerException(); |
| 1137 | 14 this.response = response; |
| 15 } | |
| 16 | |
| 17 @Override public void close() throws IOException { | |
| 18 super.close(); | |
| 19 int size = size(); | |
| 20 response.body = new Response.Body( size, new ByteArrayInputStream(buf,0,size) ); | |
| 21 } | |
| 22 } |
