1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.http;
17
18
19
20
21 public class DefaultHttpResponse extends DefaultHttpMessage implements HttpResponse {
22
23 private HttpResponseStatus status;
24
25
26
27
28
29
30
31 public DefaultHttpResponse(HttpVersion version, HttpResponseStatus status) {
32 this(version, status, true);
33 }
34
35
36
37
38
39
40
41
42 public DefaultHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders) {
43 super(version, validateHeaders);
44 if (status == null) {
45 throw new NullPointerException("status");
46 }
47 this.status = status;
48 }
49
50 @Override
51 public HttpResponseStatus getStatus() {
52 return status;
53 }
54
55 @Override
56 public HttpResponse setStatus(HttpResponseStatus status) {
57 if (status == null) {
58 throw new NullPointerException("status");
59 }
60 this.status = status;
61 return this;
62 }
63
64 @Override
65 public HttpResponse setProtocolVersion(HttpVersion version) {
66 super.setProtocolVersion(version);
67 return this;
68 }
69
70 @Override
71 public String toString() {
72 return HttpMessageUtil.appendResponse(new StringBuilder(256), this).toString();
73 }
74 }