Mercurial Hosting > luan
annotate src/goodjava/webserver/ResponseOutputStream.java @ 1810:3c43b07e12b7
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 12 May 2024 22:00:42 -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 // 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 } |