1 package org.apache.commons.fileupload; 2 3 import java.io.BufferedReader ; 4 import java.io.ByteArrayInputStream ; 5 import java.io.IOException ; 6 import java.io.UnsupportedEncodingException ; 7 import java.security.Principal ; 8 import java.util.Enumeration ; 9 import java.util.Locale ; 10 import java.util.Map ; 11 12 import javax.servlet.RequestDispatcher ; 13 import javax.servlet.ServletInputStream ; 14 import javax.servlet.http.Cookie ; 15 import javax.servlet.http.HttpServletRequest ; 16 import javax.servlet.http.HttpSession ; 17 18 26 class MyHttpServletRequest implements HttpServletRequest 27 { 28 29 private byte[] m_requestData; 30 private String m_strContentType; 31 private Map m_headers = new java.util.HashMap (); 32 33 public MyHttpServletRequest( 34 final byte[] requestData, 35 final String strContentType) 36 { 37 m_requestData = requestData; 38 m_strContentType = strContentType; 39 m_headers.put(FileUploadBase.CONTENT_TYPE, strContentType); 40 } 41 42 45 public String getAuthType() 46 { 47 return null; 48 } 49 50 53 public Cookie [] getCookies() 54 { 55 return null; 56 } 57 58 61 public long getDateHeader(String arg0) 62 { 63 return 0; 64 } 65 66 69 public String getHeader(String headerName) 70 { 71 return (String ) m_headers.get(headerName); 72 } 73 74 77 public Enumeration getHeaders(String arg0) 78 { 79 return null; 81 } 82 83 86 public Enumeration getHeaderNames() 87 { 88 return null; 90 } 91 92 95 public int getIntHeader(String arg0) 96 { 97 return 0; 98 } 99 100 103 public String getMethod() 104 { 105 return null; 106 } 107 108 111 public String getPathInfo() 112 { 113 return null; 114 } 115 116 119 public String getPathTranslated() 120 { 121 return null; 122 } 123 124 127 public String getContextPath() 128 { 129 return null; 130 } 131 132 135 public String getQueryString() 136 { 137 return null; 138 } 139 140 143 public String getRemoteUser() 144 { 145 return null; 146 } 147 148 151 public boolean isUserInRole(String arg0) 152 { 153 return false; 154 } 155 156 159 public Principal getUserPrincipal() 160 { 161 return null; 162 } 163 164 167 public String getRequestedSessionId() 168 { 169 return null; 170 } 171 172 175 public String getRequestURI() 176 { 177 return null; 178 } 179 180 183 public StringBuffer getRequestURL() 184 { 185 return null; 186 } 187 188 191 public String getServletPath() 192 { 193 return null; 194 } 195 196 199 public HttpSession getSession(boolean arg0) 200 { 201 return null; 202 } 203 204 207 public HttpSession getSession() 208 { 209 return null; 210 } 211 212 215 public boolean isRequestedSessionIdValid() 216 { 217 return false; 218 } 219 220 223 public boolean isRequestedSessionIdFromCookie() 224 { 225 return false; 226 } 227 228 231 public boolean isRequestedSessionIdFromURL() 232 { 233 return false; 234 } 235 236 240 public boolean isRequestedSessionIdFromUrl() 241 { 242 return false; 243 } 244 245 248 public Object getAttribute(String arg0) 249 { 250 return null; 251 } 252 253 256 public Enumeration getAttributeNames() 257 { 258 return null; 259 } 260 261 264 public String getCharacterEncoding() 265 { 266 return null; 267 } 268 269 272 public void setCharacterEncoding(String arg0) 273 throws UnsupportedEncodingException 274 { 275 } 276 277 280 public int getContentLength() 281 { 282 int iLength = 0; 283 284 if (null == m_requestData) 285 { 286 iLength = -1; 287 } 288 else 289 { 290 iLength = m_requestData.length; 291 } 292 return iLength; 293 } 294 295 298 public String getContentType() 299 { 300 return m_strContentType; 301 } 302 303 306 public ServletInputStream getInputStream() throws IOException 307 { 308 ServletInputStream sis = new MyServletInputStream(m_requestData); 309 return sis; 310 } 311 312 315 public String getParameter(String arg0) 316 { 317 return null; 318 } 319 320 323 public Enumeration getParameterNames() 324 { 325 return null; 326 } 327 328 331 public String [] getParameterValues(String arg0) 332 { 333 return null; 334 } 335 336 339 public Map getParameterMap() 340 { 341 return null; 342 } 343 344 347 public String getProtocol() 348 { 349 return null; 350 } 351 352 355 public String getScheme() 356 { 357 return null; 358 } 359 360 363 public String getServerName() 364 { 365 return null; 366 } 367 368 371 public int getServerPort() 372 { 373 return 0; 374 } 375 376 379 public BufferedReader getReader() throws IOException 380 { 381 return null; 382 } 383 384 387 public String getRemoteAddr() 388 { 389 return null; 390 } 391 392 395 public String getRemoteHost() 396 { 397 return null; 398 } 399 400 403 public void setAttribute(String arg0, Object arg1) 404 { 405 } 406 407 410 public void removeAttribute(String arg0) 411 { 412 } 413 414 417 public Locale getLocale() 418 { 419 return null; 420 } 421 422 425 public Enumeration getLocales() 426 { 427 return null; 428 } 429 430 433 public boolean isSecure() 434 { 435 return false; 436 } 437 438 441 public RequestDispatcher getRequestDispatcher(String arg0) 442 { 443 return null; 444 } 445 446 450 public String getRealPath(String arg0) 451 { 452 return null; 453 } 454 455 461 private static class MyServletInputStream 462 extends javax.servlet.ServletInputStream 463 { 464 private ByteArrayInputStream m_bais; 465 466 public MyServletInputStream(byte[] data) 467 { 468 m_bais = new ByteArrayInputStream (data); 469 } 470 471 public int read() 472 { 473 return m_bais.read(); 474 } 475 } 476 } 477 | Popular Tags |