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 DefaultHttpRequest extends DefaultHttpMessage implements HttpRequest {
22
23 private HttpMethod method;
24 private String uri;
25
26
27
28
29
30
31
32
33 public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri) {
34 this(httpVersion, method, uri, true);
35 }
36
37
38
39
40
41
42
43
44
45 public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri, boolean validateHeaders) {
46 super(httpVersion, validateHeaders);
47 if (method == null) {
48 throw new NullPointerException("method");
49 }
50 if (uri == null) {
51 throw new NullPointerException("uri");
52 }
53 this.method = method;
54 this.uri = uri;
55 }
56
57 @Override
58 public HttpMethod getMethod() {
59 return method;
60 }
61
62 @Override
63 public String getUri() {
64 return uri;
65 }
66
67 @Override
68 public HttpRequest setMethod(HttpMethod method) {
69 if (method == null) {
70 throw new NullPointerException("method");
71 }
72 this.method = method;
73 return this;
74 }
75
76 @Override
77 public HttpRequest setUri(String uri) {
78 if (uri == null) {
79 throw new NullPointerException("uri");
80 }
81 this.uri = uri;
82 return this;
83 }
84
85 @Override
86 public HttpRequest setProtocolVersion(HttpVersion version) {
87 super.setProtocolVersion(version);
88 return this;
89 }
90
91 @Override
92 public String toString() {
93 return HttpMessageUtil.appendRequest(new StringBuilder(256), this).toString();
94 }
95 }