Mercurial Hosting > luan
comparison src/goodjava/webserver/ResponseOutputStream.java @ 2008:bba3e529e346 default tip
chunked encoding
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 27 Aug 2025 01:14:17 -0600 |
parents | 27efb1fcbcb5 |
children |
comparison
equal
deleted
inserted
replaced
2007:408f7dd7e503 | 2008:bba3e529e346 |
---|---|
3 import java.io.ByteArrayOutputStream; | 3 import java.io.ByteArrayOutputStream; |
4 import java.io.ByteArrayInputStream; | 4 import java.io.ByteArrayInputStream; |
5 import java.io.IOException; | 5 import java.io.IOException; |
6 | 6 |
7 | 7 |
8 // plenty of room for improvement | |
9 public class ResponseOutputStream extends ByteArrayOutputStream { | 8 public class ResponseOutputStream extends ByteArrayOutputStream { |
10 private final Response response; | 9 private final Response response; |
11 | 10 |
12 public ResponseOutputStream(Response response) { | 11 public ResponseOutputStream(Response response) { |
13 if(response==null) throw new NullPointerException(); | 12 if(response==null) throw new NullPointerException(); |
15 } | 14 } |
16 | 15 |
17 @Override public void close() throws IOException { | 16 @Override public void close() throws IOException { |
18 super.close(); | 17 super.close(); |
19 int size = size(); | 18 int size = size(); |
20 response.body = new Response.Body( size, new ByteArrayInputStream(buf,0,size) ); | 19 response.headers.put("Content-Length",Long.toString(size)); |
20 response.body = new ByteArrayInputStream(buf,0,size); | |
21 } | 21 } |
22 } | 22 } |