1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.http.client.methods;
29
30 import java.net.URI;
31
32 import org.apache.http.ProtocolVersion;
33 import org.apache.http.RequestLine;
34 import org.apache.http.client.config.RequestConfig;
35 import org.apache.http.message.BasicRequestLine;
36 import org.apache.http.params.HttpProtocolParams;
37
38
39
40
41
42
43 @SuppressWarnings("deprecation")
44 public abstract class HttpRequestBase extends AbstractExecutionAwareRequest
45 implements HttpUriRequest, Configurable {
46
47 private ProtocolVersion version;
48 private URI uri;
49 private RequestConfig config;
50
51 @Override
52 public abstract String getMethod();
53
54
55
56
57 public void setProtocolVersion(final ProtocolVersion version) {
58 this.version = version;
59 }
60
61 @Override
62 public ProtocolVersion getProtocolVersion() {
63 return version != null ? version : HttpProtocolParams.getVersion(getParams());
64 }
65
66
67
68
69
70
71
72 @Override
73 public URI getURI() {
74 return this.uri;
75 }
76
77 @Override
78 public RequestLine getRequestLine() {
79 final String method = getMethod();
80 final ProtocolVersion ver = getProtocolVersion();
81 final URI uriCopy = getURI();
82 String uritext = null;
83 if (uriCopy != null) {
84 uritext = uriCopy.toASCIIString();
85 }
86 if (uritext == null || uritext.isEmpty()) {
87 uritext = "/";
88 }
89 return new BasicRequestLine(method, uritext, ver);
90 }
91
92
93 @Override
94 public RequestConfig getConfig() {
95 return config;
96 }
97
98 public void setConfig(final RequestConfig config) {
99 this.config = config;
100 }
101
102 public void setURI(final URI uri) {
103 this.uri = uri;
104 }
105
106
107
108
109 public void started() {
110 }
111
112
113
114
115
116
117
118 public void releaseConnection() {
119 reset();
120 }
121
122 @Override
123 public String toString() {
124 return getMethod() + " " + getURI() + " " + getProtocolVersion();
125 }
126
127 }