1 28 29 package HTTPClient; 30 31 32 39 40 public final class Request implements RoRequest 41 { 42 43 private static final NVPair[] empty = new NVPair[0]; 44 45 46 private HTTPConnection connection; 47 48 49 private String method; 50 51 52 private String req_uri; 53 54 55 private NVPair[] headers; 56 57 58 private byte[] data; 59 60 61 private HttpOutputStream stream; 62 63 64 private boolean allow_ui; 65 66 68 long delay_entity = 0; 69 70 71 int num_retries = 0; 72 73 74 boolean dont_pipeline = false; 75 76 77 boolean aborted = false; 78 79 80 boolean internal_subrequest = false; 81 82 83 85 96 public Request(HTTPConnection con, String method, String req_uri, 97 NVPair[] headers, byte[] data, HttpOutputStream stream, 98 boolean allow_ui) 99 { 100 this.connection = con; 101 this.method = method; 102 setRequestURI(req_uri); 103 setHeaders(headers); 104 this.data = data; 105 this.stream = stream; 106 this.allow_ui = allow_ui; 107 } 108 109 110 112 115 public HTTPConnection getConnection() 116 { 117 return connection; 118 } 119 120 123 public void setConnection(HTTPConnection con) 124 { 125 this.connection = con; 126 } 127 128 129 132 public String getMethod() 133 { 134 return method; 135 } 136 137 140 public void setMethod(String method) 141 { 142 this.method = method; 143 } 144 145 146 149 public String getRequestURI() 150 { 151 return req_uri; 152 } 153 154 157 public void setRequestURI(String req_uri) 158 { 159 if (req_uri != null && req_uri.trim().length() > 0) 160 { 161 req_uri = req_uri.trim(); 162 if (req_uri.charAt(0) != '/' && !req_uri.equals("*")) 163 req_uri = "/" + req_uri; 164 this.req_uri = req_uri; 165 } 166 else 167 this.req_uri = "/"; 168 } 169 170 171 174 public NVPair[] getHeaders() 175 { 176 return headers; 177 } 178 179 182 public void setHeaders(NVPair[] headers) 183 { 184 if (headers != null) 185 this.headers = headers; 186 else 187 this.headers = empty; 188 } 189 190 191 194 public byte[] getData() 195 { 196 return data; 197 } 198 199 202 public void setData(byte[] data) 203 { 204 this.data = data; 205 } 206 207 208 211 public HttpOutputStream getStream() 212 { 213 return stream; 214 } 215 216 219 public void setStream(HttpOutputStream stream) 220 { 221 this.stream = stream; 222 } 223 224 225 229 public boolean allowUI() 230 { 231 return allow_ui; 232 } 233 234 238 public void setAllowUI(boolean allow_ui) 239 { 240 this.allow_ui = allow_ui; 241 } 242 243 244 247 public String toString() 248 { 249 return getClass().getName() + ": " + method + " " + req_uri; 250 } 251 } 252 253 | Popular Tags |