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 org.jboss.netty.util.internal.StringUtil;
19
20
21
22
23
24
25
26
27
28 public class DefaultHttpRequest extends DefaultHttpMessage implements HttpRequest {
29
30 private HttpMethod method;
31 private String uri;
32
33
34
35
36
37
38
39
40 public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri) {
41 super(httpVersion);
42 setMethod(method);
43 setUri(uri);
44 }
45
46 public HttpMethod getMethod() {
47 return method;
48 }
49
50 public void setMethod(HttpMethod method) {
51 if (method == null) {
52 throw new NullPointerException("method");
53 }
54 this.method = method;
55 }
56
57 public String getUri() {
58 return uri;
59 }
60
61 public void setUri(String uri) {
62 if (uri == null) {
63 throw new NullPointerException("uri");
64 }
65 this.uri = uri;
66 }
67
68 @Override
69 public String toString() {
70 StringBuilder buf = new StringBuilder();
71 buf.append(getClass().getSimpleName());
72 buf.append("(chunked: ");
73 buf.append(isChunked());
74 buf.append(')');
75 buf.append(StringUtil.NEWLINE);
76 buf.append(getMethod().toString());
77 buf.append(' ');
78 buf.append(getUri());
79 buf.append(' ');
80 buf.append(getProtocolVersion().getText());
81 buf.append(StringUtil.NEWLINE);
82 appendHeaders(buf);
83
84
85 buf.setLength(buf.length() - StringUtil.NEWLINE.length());
86 return buf.toString();
87 }
88 }