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