comparison 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
comparison
equal deleted inserted replaced
1401:ef1620aa99cb 1402:27efb1fcbcb5
1 package goodjava.webserver;
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) {
13 if(response==null) throw new NullPointerException();
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 }