1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.codec.http;
17
18 import static org.jboss.netty.handler.codec.http.HttpConstants.*;
19
20 import org.jboss.netty.buffer.ChannelBuffer;
21
22
23
24
25
26 public class HttpResponseEncoder extends HttpMessageEncoder {
27
28
29
30
31 public HttpResponseEncoder() {
32 super();
33 }
34
35 @Override
36 protected void encodeInitialLine(ChannelBuffer buf, HttpMessage message) throws Exception {
37 HttpResponse response = (HttpResponse) message;
38 buf.writeBytes(response.getProtocolVersion().toString().getBytes("ASCII"));
39 buf.writeByte(SP);
40 buf.writeBytes(String.valueOf(response.getStatus().getCode()).getBytes("ASCII"));
41 buf.writeByte(SP);
42 buf.writeBytes(String.valueOf(response.getStatus().getReasonPhrase()).getBytes("ASCII"));
43 buf.writeByte(CR);
44 buf.writeByte(LF);
45 }
46 }