Mercurial Hosting > luan
annotate src/goodjava/webserver/ResponseOutputStream.java @ 1477:509736ad42e6
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 21 Apr 2020 15:05:39 -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 } |