PageRenderTime 82ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/tomcat-7.0.2/java/org/apache/catalina/connector/Request.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 1815 lines | 795 code | 378 blank | 642 comment | 141 complexity | df02a215293e28035e7961909d863dda MD5 | raw file
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.catalina.connector;
  18. import java.io.BufferedReader;
  19. import java.io.File;
  20. import java.io.IOException;
  21. import java.io.InputStream;
  22. import java.io.UnsupportedEncodingException;
  23. import java.security.Principal;
  24. import java.text.SimpleDateFormat;
  25. import java.util.ArrayList;
  26. import java.util.Collection;
  27. import java.util.Collections;
  28. import java.util.Enumeration;
  29. import java.util.HashMap;
  30. import java.util.Iterator;
  31. import java.util.List;
  32. import java.util.Locale;
  33. import java.util.Map;
  34. import java.util.TimeZone;
  35. import java.util.TreeMap;
  36. import javax.security.auth.Subject;
  37. import javax.servlet.AsyncContext;
  38. import javax.servlet.DispatcherType;
  39. import javax.servlet.FilterChain;
  40. import javax.servlet.MultipartConfigElement;
  41. import javax.servlet.RequestDispatcher;
  42. import javax.servlet.ServletContext;
  43. import javax.servlet.ServletException;
  44. import javax.servlet.ServletInputStream;
  45. import javax.servlet.ServletRequest;
  46. import javax.servlet.ServletRequestAttributeEvent;
  47. import javax.servlet.ServletRequestAttributeListener;
  48. import javax.servlet.ServletResponse;
  49. import javax.servlet.SessionTrackingMode;
  50. import javax.servlet.http.Cookie;
  51. import javax.servlet.http.HttpServletRequest;
  52. import javax.servlet.http.HttpServletResponse;
  53. import javax.servlet.http.HttpSession;
  54. import javax.servlet.http.Part;
  55. import org.apache.catalina.Context;
  56. import org.apache.catalina.Globals;
  57. import org.apache.catalina.Host;
  58. import org.apache.catalina.Manager;
  59. import org.apache.catalina.Realm;
  60. import org.apache.catalina.Session;
  61. import org.apache.catalina.Wrapper;
  62. import org.apache.catalina.core.ApplicationSessionCookieConfig;
  63. import org.apache.catalina.core.AsyncContextImpl;
  64. import org.apache.catalina.core.ApplicationPart;
  65. import org.apache.catalina.deploy.LoginConfig;
  66. import org.apache.catalina.realm.GenericPrincipal;
  67. import org.apache.catalina.util.Enumerator;
  68. import org.apache.catalina.util.ParameterMap;
  69. import org.apache.catalina.util.StringParser;
  70. import org.apache.coyote.ActionCode;
  71. import org.apache.tomcat.util.buf.B2CConverter;
  72. import org.apache.tomcat.util.buf.ByteChunk;
  73. import org.apache.tomcat.util.buf.MessageBytes;
  74. import org.apache.tomcat.util.buf.StringCache;
  75. import org.apache.tomcat.util.http.Cookies;
  76. import org.apache.tomcat.util.http.FastHttpDateFormat;
  77. import org.apache.tomcat.util.http.Parameters;
  78. import org.apache.tomcat.util.http.ServerCookie;
  79. import org.apache.tomcat.util.http.fileupload.FileItem;
  80. import org.apache.tomcat.util.http.fileupload.FileUploadBase;
  81. import org.apache.tomcat.util.http.fileupload.FileUploadException;
  82. import org.apache.tomcat.util.http.fileupload.FileUploadBase.InvalidContentTypeException;
  83. import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
  84. import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
  85. import org.apache.tomcat.util.http.mapper.MappingData;
  86. import org.apache.tomcat.util.res.StringManager;
  87. /**
  88. * Wrapper object for the Coyote request.
  89. *
  90. * @author Remy Maucherat
  91. * @author Craig R. McClanahan
  92. * @version $Id: Request.java 981190 2010-08-01 09:52:35Z markt $
  93. */
  94. public class Request
  95. implements HttpServletRequest {
  96. // ----------------------------------------------------------- Constructors
  97. static {
  98. // Ensure that classes are loaded for SM
  99. new StringCache.ByteEntry();
  100. new StringCache.CharEntry();
  101. }
  102. public Request() {
  103. formats[0].setTimeZone(GMT_ZONE);
  104. formats[1].setTimeZone(GMT_ZONE);
  105. formats[2].setTimeZone(GMT_ZONE);
  106. }
  107. // ------------------------------------------------------------- Properties
  108. /**
  109. * Coyote request.
  110. */
  111. protected org.apache.coyote.Request coyoteRequest;
  112. /**
  113. * Set the Coyote request.
  114. *
  115. * @param coyoteRequest The Coyote request
  116. */
  117. public void setCoyoteRequest(org.apache.coyote.Request coyoteRequest) {
  118. this.coyoteRequest = coyoteRequest;
  119. inputBuffer.setRequest(coyoteRequest);
  120. }
  121. /**
  122. * Get the Coyote request.
  123. */
  124. public org.apache.coyote.Request getCoyoteRequest() {
  125. return (this.coyoteRequest);
  126. }
  127. // ----------------------------------------------------- Variables
  128. protected static final TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
  129. /**
  130. * The string manager for this package.
  131. */
  132. protected static final StringManager sm =
  133. StringManager.getManager(Constants.Package);
  134. /**
  135. * The set of cookies associated with this Request.
  136. */
  137. protected Cookie[] cookies = null;
  138. /**
  139. * The set of SimpleDateFormat formats to use in getDateHeader().
  140. *
  141. * Notice that because SimpleDateFormat is not thread-safe, we can't
  142. * declare formats[] as a static variable.
  143. */
  144. protected SimpleDateFormat formats[] = {
  145. new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
  146. new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
  147. new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
  148. };
  149. /**
  150. * The default Locale if none are specified.
  151. */
  152. protected static Locale defaultLocale = Locale.getDefault();
  153. /**
  154. * The attributes associated with this Request, keyed by attribute name.
  155. */
  156. protected HashMap<String, Object> attributes =
  157. new HashMap<String, Object>();
  158. /**
  159. * Flag that indicates if SSL attributes have been parsed to improve
  160. * performance for applications (usually frameworks) that make multiple
  161. * calls to {@link Request#getAttributeNames()}.
  162. */
  163. protected boolean sslAttributesParsed = false;
  164. /**
  165. * List of read only attributes for this Request.
  166. */
  167. private HashMap<String,Object> readOnlyAttributes =
  168. new HashMap<String,Object>();
  169. /**
  170. * The preferred Locales associated with this Request.
  171. */
  172. protected ArrayList<Locale> locales = new ArrayList<Locale>();
  173. /**
  174. * Internal notes associated with this request by Catalina components
  175. * and event listeners.
  176. */
  177. private transient HashMap<String, Object> notes = new HashMap<String, Object>();
  178. /**
  179. * Authentication type.
  180. */
  181. protected String authType = null;
  182. /**
  183. * Associated event.
  184. */
  185. protected CometEventImpl event = null;
  186. /**
  187. * Comet state
  188. */
  189. protected boolean comet = false;
  190. /**
  191. * The current dispatcher type.
  192. */
  193. protected DispatcherType internalDispatcherType = null;
  194. /**
  195. * The associated input buffer.
  196. */
  197. protected InputBuffer inputBuffer = new InputBuffer();
  198. /**
  199. * ServletInputStream.
  200. */
  201. protected CoyoteInputStream inputStream =
  202. new CoyoteInputStream(inputBuffer);
  203. /**
  204. * Reader.
  205. */
  206. protected CoyoteReader reader = new CoyoteReader(inputBuffer);
  207. /**
  208. * Using stream flag.
  209. */
  210. protected boolean usingInputStream = false;
  211. /**
  212. * Using writer flag.
  213. */
  214. protected boolean usingReader = false;
  215. /**
  216. * User principal.
  217. */
  218. protected Principal userPrincipal = null;
  219. /**
  220. * Session parsed flag.
  221. */
  222. protected boolean sessionParsed = false;
  223. /**
  224. * Request parameters parsed flag.
  225. */
  226. protected boolean parametersParsed = false;
  227. /**
  228. * Cookies parsed flag.
  229. */
  230. protected boolean cookiesParsed = false;
  231. /**
  232. * Secure flag.
  233. */
  234. protected boolean secure = false;
  235. /**
  236. * The Subject associated with the current AccessControllerContext
  237. */
  238. protected transient Subject subject = null;
  239. /**
  240. * Post data buffer.
  241. */
  242. protected static int CACHED_POST_LEN = 8192;
  243. protected byte[] postData = null;
  244. /**
  245. * Hash map used in the getParametersMap method.
  246. */
  247. protected ParameterMap<String, String[]> parameterMap = new ParameterMap<String, String[]>();
  248. /**
  249. * The parts, if any, uploaded with this request.
  250. */
  251. protected Collection<Part> parts = null;
  252. /**
  253. * The exception thrown, if any when parsing the parts.
  254. */
  255. protected Exception partsParseException = null;
  256. /**
  257. * The currently active session for this request.
  258. */
  259. protected Session session = null;
  260. /**
  261. * The current request dispatcher path.
  262. */
  263. protected Object requestDispatcherPath = null;
  264. /**
  265. * Was the requested session ID received in a cookie?
  266. */
  267. protected boolean requestedSessionCookie = false;
  268. /**
  269. * The requested session ID (if any) for this request.
  270. */
  271. protected String requestedSessionId = null;
  272. /**
  273. * Was the requested session ID received in a URL?
  274. */
  275. protected boolean requestedSessionURL = false;
  276. /**
  277. * Was the requested session ID obtained from the SSL session?
  278. */
  279. protected boolean requestedSessionSSL = false;
  280. /**
  281. * Parse locales.
  282. */
  283. protected boolean localesParsed = false;
  284. /**
  285. * The string parser we will use for parsing request lines.
  286. */
  287. private StringParser parser = new StringParser();
  288. /**
  289. * Local port
  290. */
  291. protected int localPort = -1;
  292. /**
  293. * Remote address.
  294. */
  295. protected String remoteAddr = null;
  296. /**
  297. * Remote host.
  298. */
  299. protected String remoteHost = null;
  300. /**
  301. * Remote port
  302. */
  303. protected int remotePort = -1;
  304. /**
  305. * Local address
  306. */
  307. protected String localAddr = null;
  308. /**
  309. * Local address
  310. */
  311. protected String localName = null;
  312. /**
  313. * AsyncContext
  314. */
  315. protected volatile AsyncContextImpl asyncContext = null;
  316. protected Boolean asyncSupported = null;
  317. /**
  318. * Path parameters
  319. */
  320. protected Map<String,String> pathParameters = new HashMap<String, String>();
  321. // --------------------------------------------------------- Public Methods
  322. protected void addPathParameter(String name, String value) {
  323. pathParameters.put(name, value);
  324. }
  325. protected String getPathParameter(String name) {
  326. return pathParameters.get(name);
  327. }
  328. public void setAsyncSupported(boolean asyncSupported) {
  329. this.asyncSupported = Boolean.valueOf(asyncSupported);
  330. }
  331. /**
  332. * Release all object references, and initialize instance variables, in
  333. * preparation for reuse of this object.
  334. */
  335. public void recycle() {
  336. context = null;
  337. wrapper = null;
  338. internalDispatcherType = null;
  339. requestDispatcherPath = null;
  340. comet = false;
  341. if (event != null) {
  342. event.clear();
  343. event = null;
  344. }
  345. authType = null;
  346. inputBuffer.recycle();
  347. usingInputStream = false;
  348. usingReader = false;
  349. userPrincipal = null;
  350. subject = null;
  351. sessionParsed = false;
  352. parametersParsed = false;
  353. parts = null;
  354. partsParseException = null;
  355. cookiesParsed = false;
  356. locales.clear();
  357. localesParsed = false;
  358. secure = false;
  359. remoteAddr = null;
  360. remoteHost = null;
  361. remotePort = -1;
  362. localPort = -1;
  363. localAddr = null;
  364. localName = null;
  365. attributes.clear();
  366. sslAttributesParsed = false;
  367. notes.clear();
  368. cookies = null;
  369. if (session != null) {
  370. session.endAccess();
  371. }
  372. session = null;
  373. requestedSessionCookie = false;
  374. requestedSessionId = null;
  375. requestedSessionURL = false;
  376. if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) {
  377. parameterMap = new ParameterMap<String, String[]>();
  378. } else {
  379. parameterMap.setLocked(false);
  380. parameterMap.clear();
  381. }
  382. mappingData.recycle();
  383. if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) {
  384. if (facade != null) {
  385. facade.clear();
  386. facade = null;
  387. }
  388. if (inputStream != null) {
  389. inputStream.clear();
  390. inputStream = null;
  391. }
  392. if (reader != null) {
  393. reader.clear();
  394. reader = null;
  395. }
  396. }
  397. asyncSupported = null;
  398. if (asyncContext!=null) asyncContext.recycle();
  399. asyncContext = null;
  400. pathParameters.clear();
  401. }
  402. protected boolean isProcessing() {
  403. return coyoteRequest.isProcessing();
  404. }
  405. /**
  406. * Clear cached encoders (to save memory for Comet requests).
  407. */
  408. public void clearEncoders() {
  409. inputBuffer.clearEncoders();
  410. }
  411. /**
  412. * Clear cached encoders (to save memory for Comet requests).
  413. */
  414. public boolean read()
  415. throws IOException {
  416. return (inputBuffer.realReadBytes(null, 0, 0) > 0);
  417. }
  418. // -------------------------------------------------------- Request Methods
  419. /**
  420. * Associated Catalina connector.
  421. */
  422. protected Connector connector;
  423. /**
  424. * Return the Connector through which this Request was received.
  425. */
  426. public Connector getConnector() {
  427. return this.connector;
  428. }
  429. /**
  430. * Set the Connector through which this Request was received.
  431. *
  432. * @param connector The new connector
  433. */
  434. public void setConnector(Connector connector) {
  435. this.connector = connector;
  436. }
  437. /**
  438. * Associated context.
  439. */
  440. protected Context context = null;
  441. /**
  442. * Return the Context within which this Request is being processed.
  443. */
  444. public Context getContext() {
  445. return this.context;
  446. }
  447. /**
  448. * Set the Context within which this Request is being processed. This
  449. * must be called as soon as the appropriate Context is identified, because
  450. * it identifies the value to be returned by <code>getContextPath()</code>,
  451. * and thus enables parsing of the request URI.
  452. *
  453. * @param context The newly associated Context
  454. */
  455. public void setContext(Context context) {
  456. this.context = context;
  457. }
  458. /**
  459. * Filter chain associated with the request.
  460. */
  461. protected FilterChain filterChain = null;
  462. /**
  463. * Get filter chain associated with the request.
  464. */
  465. public FilterChain getFilterChain() {
  466. return this.filterChain;
  467. }
  468. /**
  469. * Set filter chain associated with the request.
  470. *
  471. * @param filterChain new filter chain
  472. */
  473. public void setFilterChain(FilterChain filterChain) {
  474. this.filterChain = filterChain;
  475. }
  476. /**
  477. * Return the Host within which this Request is being processed.
  478. */
  479. public Host getHost() {
  480. return ((Host) mappingData.host);
  481. }
  482. /**
  483. * Set the Host within which this Request is being processed. This
  484. * must be called as soon as the appropriate Host is identified, and
  485. * before the Request is passed to a context.
  486. *
  487. * @param host The newly associated Host
  488. */
  489. public void setHost(Host host) {
  490. mappingData.host = host;
  491. }
  492. /**
  493. * Descriptive information about this Request implementation.
  494. */
  495. protected static final String info =
  496. "org.apache.coyote.catalina.CoyoteRequest/1.0";
  497. /**
  498. * Return descriptive information about this Request implementation and
  499. * the corresponding version number, in the format
  500. * <code>&lt;description&gt;/&lt;version&gt;</code>.
  501. */
  502. public String getInfo() {
  503. return info;
  504. }
  505. /**
  506. * Mapping data.
  507. */
  508. protected MappingData mappingData = new MappingData();
  509. /**
  510. * Return mapping data.
  511. */
  512. public MappingData getMappingData() {
  513. return mappingData;
  514. }
  515. /**
  516. * The facade associated with this request.
  517. */
  518. protected RequestFacade facade = null;
  519. /**
  520. * Return the <code>ServletRequest</code> for which this object
  521. * is the facade. This method must be implemented by a subclass.
  522. */
  523. public HttpServletRequest getRequest() {
  524. if (facade == null) {
  525. facade = new RequestFacade(this);
  526. }
  527. return facade;
  528. }
  529. /**
  530. * The response with which this request is associated.
  531. */
  532. protected org.apache.catalina.connector.Response response = null;
  533. /**
  534. * Return the Response with which this Request is associated.
  535. */
  536. public org.apache.catalina.connector.Response getResponse() {
  537. return this.response;
  538. }
  539. /**
  540. * Set the Response with which this Request is associated.
  541. *
  542. * @param response The new associated response
  543. */
  544. public void setResponse(org.apache.catalina.connector.Response response) {
  545. this.response = response;
  546. }
  547. /**
  548. * Return the input stream associated with this Request.
  549. */
  550. public InputStream getStream() {
  551. if (inputStream == null) {
  552. inputStream = new CoyoteInputStream(inputBuffer);
  553. }
  554. return inputStream;
  555. }
  556. /**
  557. * URI byte to char converter (not recycled).
  558. */
  559. protected B2CConverter URIConverter = null;
  560. /**
  561. * Return the URI converter.
  562. */
  563. protected B2CConverter getURIConverter() {
  564. return URIConverter;
  565. }
  566. /**
  567. * Set the URI converter.
  568. *
  569. * @param URIConverter the new URI converter
  570. */
  571. protected void setURIConverter(B2CConverter URIConverter) {
  572. this.URIConverter = URIConverter;
  573. }
  574. /**
  575. * Associated wrapper.
  576. */
  577. protected Wrapper wrapper = null;
  578. /**
  579. * Return the Wrapper within which this Request is being processed.
  580. */
  581. public Wrapper getWrapper() {
  582. return this.wrapper;
  583. }
  584. /**
  585. * Set the Wrapper within which this Request is being processed. This
  586. * must be called as soon as the appropriate Wrapper is identified, and
  587. * before the Request is ultimately passed to an application servlet.
  588. * @param wrapper The newly associated Wrapper
  589. */
  590. public void setWrapper(Wrapper wrapper) {
  591. this.wrapper = wrapper;
  592. }
  593. // ------------------------------------------------- Request Public Methods
  594. /**
  595. * Create and return a ServletInputStream to read the content
  596. * associated with this Request.
  597. *
  598. * @exception IOException if an input/output error occurs
  599. */
  600. public ServletInputStream createInputStream()
  601. throws IOException {
  602. if (inputStream == null) {
  603. inputStream = new CoyoteInputStream(inputBuffer);
  604. }
  605. return inputStream;
  606. }
  607. /**
  608. * Perform whatever actions are required to flush and close the input
  609. * stream or reader, in a single operation.
  610. *
  611. * @exception IOException if an input/output error occurs
  612. */
  613. public void finishRequest() throws IOException {
  614. // The reader and input stream don't need to be closed
  615. }
  616. /**
  617. * Return the object bound with the specified name to the internal notes
  618. * for this request, or <code>null</code> if no such binding exists.
  619. *
  620. * @param name Name of the note to be returned
  621. */
  622. public Object getNote(String name) {
  623. return notes.get(name);
  624. }
  625. /**
  626. * Return an Iterator containing the String names of all notes bindings
  627. * that exist for this request.
  628. */
  629. public Iterator<String> getNoteNames() {
  630. return notes.keySet().iterator();
  631. }
  632. /**
  633. * Remove any object bound to the specified name in the internal notes
  634. * for this request.
  635. *
  636. * @param name Name of the note to be removed
  637. */
  638. public void removeNote(String name) {
  639. notes.remove(name);
  640. }
  641. /**
  642. * Bind an object to a specified name in the internal notes associated
  643. * with this request, replacing any existing binding for this name.
  644. *
  645. * @param name Name to which the object should be bound
  646. * @param value Object to be bound to the specified name
  647. */
  648. public void setNote(String name, Object value) {
  649. notes.put(name, value);
  650. }
  651. /**
  652. * Set the IP address of the remote client associated with this Request.
  653. *
  654. * @param remoteAddr The remote IP address
  655. */
  656. public void setRemoteAddr(String remoteAddr) {
  657. this.remoteAddr = remoteAddr;
  658. }
  659. /**
  660. * Set the fully qualified name of the remote client associated with this
  661. * Request.
  662. *
  663. * @param remoteHost The remote host name
  664. */
  665. public void setRemoteHost(String remoteHost) {
  666. this.remoteHost = remoteHost;
  667. }
  668. /**
  669. * Set the value to be returned by <code>isSecure()</code>
  670. * for this Request.
  671. *
  672. * @param secure The new isSecure value
  673. */
  674. public void setSecure(boolean secure) {
  675. this.secure = secure;
  676. }
  677. /**
  678. * Set the name of the server (virtual host) to process this request.
  679. *
  680. * @param name The server name
  681. */
  682. public void setServerName(String name) {
  683. coyoteRequest.serverName().setString(name);
  684. }
  685. /**
  686. * Set the port number of the server to process this request.
  687. *
  688. * @param port The server port
  689. */
  690. public void setServerPort(int port) {
  691. coyoteRequest.setServerPort(port);
  692. }
  693. // ------------------------------------------------- ServletRequest Methods
  694. /**
  695. * Return the specified request attribute if it exists; otherwise, return
  696. * <code>null</code>.
  697. *
  698. * @param name Name of the request attribute to return
  699. */
  700. public Object getAttribute(String name) {
  701. if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
  702. return (internalDispatcherType == null)
  703. ? DispatcherType.REQUEST
  704. : internalDispatcherType;
  705. } else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
  706. return (requestDispatcherPath == null)
  707. ? getRequestPathMB().toString()
  708. : requestDispatcherPath.toString();
  709. }
  710. if (name.equals(Globals.ASYNC_SUPPORTED_ATTR)) {
  711. return asyncSupported;
  712. }
  713. Object attr=attributes.get(name);
  714. if(attr!=null)
  715. return(attr);
  716. attr = coyoteRequest.getAttribute(name);
  717. if(attr != null)
  718. return attr;
  719. if( isSSLAttribute(name) ) {
  720. coyoteRequest.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,
  721. coyoteRequest);
  722. attr = coyoteRequest.getAttribute(Globals.CERTIFICATES_ATTR);
  723. if( attr != null) {
  724. attributes.put(Globals.CERTIFICATES_ATTR, attr);
  725. }
  726. attr = coyoteRequest.getAttribute(Globals.CIPHER_SUITE_ATTR);
  727. if(attr != null) {
  728. attributes.put(Globals.CIPHER_SUITE_ATTR, attr);
  729. }
  730. attr = coyoteRequest.getAttribute(Globals.KEY_SIZE_ATTR);
  731. if(attr != null) {
  732. attributes.put(Globals.KEY_SIZE_ATTR, attr);
  733. }
  734. attr = coyoteRequest.getAttribute(Globals.SSL_SESSION_ID_ATTR);
  735. if(attr != null) {
  736. attributes.put(Globals.SSL_SESSION_ID_ATTR, attr);
  737. }
  738. attr = coyoteRequest.getAttribute(Globals.SSL_SESSION_MGR_ATTR);
  739. if(attr != null) {
  740. attributes.put(Globals.SSL_SESSION_MGR_ATTR, attr);
  741. }
  742. attr = attributes.get(name);
  743. sslAttributesParsed = true;
  744. }
  745. return attr;
  746. }
  747. /**
  748. * Test if a given name is one of the special Servlet-spec SSL attributes.
  749. */
  750. static boolean isSSLAttribute(String name) {
  751. return Globals.CERTIFICATES_ATTR.equals(name) ||
  752. Globals.CIPHER_SUITE_ATTR.equals(name) ||
  753. Globals.KEY_SIZE_ATTR.equals(name) ||
  754. Globals.SSL_SESSION_ID_ATTR.equals(name) ||
  755. Globals.SSL_SESSION_MGR_ATTR.equals(name);
  756. }
  757. /**
  758. * Return the names of all request attributes for this Request, or an
  759. * empty <code>Enumeration</code> if there are none. Note that the attribute
  760. * names returned will only be those for the attributes set via
  761. * {@link #setAttribute(String, Object)}. Tomcat internal attributes will
  762. * not be included although they are accessible via
  763. * {@link #getAttribute(String)}. The Tomcat internal attributes include:
  764. * <ul>
  765. * <li>{@link Globals#DISPATCHER_TYPE_ATTR}</li>
  766. * <li>{@link Globals#DISPATCHER_REQUEST_PATH_ATTR}</li>
  767. * <li>{@link Globals#ASYNC_SUPPORTED_ATTR}</li>
  768. * <li>{@link Globals#CERTIFICATES_ATTR} (SSL connections only)</li>
  769. * <li>{@link Globals#CIPHER_SUITE_ATTR} (SSL connections only)</li>
  770. * <li>{@link Globals#KEY_SIZE_ATTR} (SSL connections only)</li>
  771. * <li>{@link Globals#SSL_SESSION_ID_ATTR} (SSL connections only)</li>
  772. * <li>{@link Globals#SSL_SESSION_MGR_ATTR} (SSL connections only)</li>
  773. * </ul>
  774. * The underlying connector may also expose request attributes. These all
  775. * have names starting with "org.apache.tomcat" and include:
  776. * <ul>
  777. * <li>org.apache.tomcat.sendfile.support</li>
  778. * <li>org.apache.tomcat.comet.support</li>
  779. * <li>org.apache.tomcat.comet.timeout.support</li>
  780. * </ul>
  781. * Connector implementations may return some, all or none of these
  782. * attributes and may also support additional attributes.
  783. */
  784. public Enumeration<String> getAttributeNames() {
  785. if (isSecure() && !sslAttributesParsed) {
  786. getAttribute(Globals.CERTIFICATES_ATTR);
  787. }
  788. return new Enumerator<String>(attributes.keySet(), true);
  789. }
  790. /**
  791. * Return the character encoding for this Request.
  792. */
  793. public String getCharacterEncoding() {
  794. return coyoteRequest.getCharacterEncoding();
  795. }
  796. /**
  797. * Return the content length for this Request.
  798. */
  799. public int getContentLength() {
  800. return coyoteRequest.getContentLength();
  801. }
  802. /**
  803. * Return the content type for this Request.
  804. */
  805. public String getContentType() {
  806. return coyoteRequest.getContentType();
  807. }
  808. /**
  809. * Return the servlet input stream for this Request. The default
  810. * implementation returns a servlet input stream created by
  811. * <code>createInputStream()</code>.
  812. *
  813. * @exception IllegalStateException if <code>getReader()</code> has
  814. * already been called for this request
  815. * @exception IOException if an input/output error occurs
  816. */
  817. public ServletInputStream getInputStream() throws IOException {
  818. if (usingReader)
  819. throw new IllegalStateException
  820. (sm.getString("coyoteRequest.getInputStream.ise"));
  821. usingInputStream = true;
  822. if (inputStream == null) {
  823. inputStream = new CoyoteInputStream(inputBuffer);
  824. }
  825. return inputStream;
  826. }
  827. /**
  828. * Return the preferred Locale that the client will accept content in,
  829. * based on the value for the first <code>Accept-Language</code> header
  830. * that was encountered. If the request did not specify a preferred
  831. * language, the server's default Locale is returned.
  832. */
  833. public Locale getLocale() {
  834. if (!localesParsed)
  835. parseLocales();
  836. if (locales.size() > 0) {
  837. return locales.get(0);
  838. }
  839. return defaultLocale;
  840. }
  841. /**
  842. * Return the set of preferred Locales that the client will accept
  843. * content in, based on the values for any <code>Accept-Language</code>
  844. * headers that were encountered. If the request did not specify a
  845. * preferred language, the server's default Locale is returned.
  846. */
  847. public Enumeration<Locale> getLocales() {
  848. if (!localesParsed)
  849. parseLocales();
  850. if (locales.size() > 0)
  851. return (new Enumerator<Locale>(locales));
  852. ArrayList<Locale> results = new ArrayList<Locale>();
  853. results.add(defaultLocale);
  854. return new Enumerator<Locale>(results);
  855. }
  856. /**
  857. * Return the value of the specified request parameter, if any; otherwise,
  858. * return <code>null</code>. If there is more than one value defined,
  859. * return only the first one.
  860. *
  861. * @param name Name of the desired request parameter
  862. */
  863. public String getParameter(String name) {
  864. if (!parametersParsed)
  865. parseParameters();
  866. return coyoteRequest.getParameters().getParameter(name);
  867. }
  868. /**
  869. * Returns a <code>Map</code> of the parameters of this request.
  870. * Request parameters are extra information sent with the request.
  871. * For HTTP servlets, parameters are contained in the query string
  872. * or posted form data.
  873. *
  874. * @return A <code>Map</code> containing parameter names as keys
  875. * and parameter values as map values.
  876. */
  877. public Map<String, String[]> getParameterMap() {
  878. if (parameterMap.isLocked())
  879. return parameterMap;
  880. Enumeration<String> enumeration = getParameterNames();
  881. while (enumeration.hasMoreElements()) {
  882. String name = enumeration.nextElement();
  883. String[] values = getParameterValues(name);
  884. parameterMap.put(name, values);
  885. }
  886. parameterMap.setLocked(true);
  887. return parameterMap;
  888. }
  889. /**
  890. * Return the names of all defined request parameters for this request.
  891. */
  892. public Enumeration<String> getParameterNames() {
  893. if (!parametersParsed)
  894. parseParameters();
  895. return coyoteRequest.getParameters().getParameterNames();
  896. }
  897. /**
  898. * Return the defined values for the specified request parameter, if any;
  899. * otherwise, return <code>null</code>.
  900. *
  901. * @param name Name of the desired request parameter
  902. */
  903. public String[] getParameterValues(String name) {
  904. if (!parametersParsed)
  905. parseParameters();
  906. return coyoteRequest.getParameters().getParameterValues(name);
  907. }
  908. /**
  909. * Return the protocol and version used to make this Request.
  910. */
  911. public String getProtocol() {
  912. return coyoteRequest.protocol().toString();
  913. }
  914. /**
  915. * Read the Reader wrapping the input stream for this Request. The
  916. * default implementation wraps a <code>BufferedReader</code> around the
  917. * servlet input stream returned by <code>createInputStream()</code>.
  918. *
  919. * @exception IllegalStateException if <code>getInputStream()</code>
  920. * has already been called for this request
  921. * @exception IOException if an input/output error occurs
  922. */
  923. public BufferedReader getReader() throws IOException {
  924. if (usingInputStream)
  925. throw new IllegalStateException
  926. (sm.getString("coyoteRequest.getReader.ise"));
  927. usingReader = true;
  928. inputBuffer.checkConverter();
  929. if (reader == null) {
  930. reader = new CoyoteReader(inputBuffer);
  931. }
  932. return reader;
  933. }
  934. /**
  935. * Return the real path of the specified virtual path.
  936. *
  937. * @param path Path to be translated
  938. *
  939. * @deprecated As of version 2.1 of the Java Servlet API, use
  940. * <code>ServletContext.getRealPath()</code>.
  941. */
  942. @Deprecated
  943. public String getRealPath(String path) {
  944. if (context == null)
  945. return null;
  946. ServletContext servletContext = context.getServletContext();
  947. if (servletContext == null) {
  948. return null;
  949. }
  950. try {
  951. return (servletContext.getRealPath(path));
  952. } catch (IllegalArgumentException e) {
  953. return null;
  954. }
  955. }
  956. /**
  957. * Return the remote IP address making this Request.
  958. */
  959. public String getRemoteAddr() {
  960. if (remoteAddr == null) {
  961. coyoteRequest.action
  962. (ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE, coyoteRequest);
  963. remoteAddr = coyoteRequest.remoteAddr().toString();
  964. }
  965. return remoteAddr;
  966. }
  967. /**
  968. * Return the remote host name making this Request.
  969. */
  970. public String getRemoteHost() {
  971. if (remoteHost == null) {
  972. if (!connector.getEnableLookups()) {
  973. remoteHost = getRemoteAddr();
  974. } else {
  975. coyoteRequest.action
  976. (ActionCode.ACTION_REQ_HOST_ATTRIBUTE, coyoteRequest);
  977. remoteHost = coyoteRequest.remoteHost().toString();
  978. }
  979. }
  980. return remoteHost;
  981. }
  982. /**
  983. * Returns the Internet Protocol (IP) source port of the client
  984. * or last proxy that sent the request.
  985. */
  986. public int getRemotePort(){
  987. if (remotePort == -1) {
  988. coyoteRequest.action
  989. (ActionCode.ACTION_REQ_REMOTEPORT_ATTRIBUTE, coyoteRequest);
  990. remotePort = coyoteRequest.getRemotePort();
  991. }
  992. return remotePort;
  993. }
  994. /**
  995. * Returns the host name of the Internet Protocol (IP) interface on
  996. * which the request was received.
  997. */
  998. public String getLocalName(){
  999. if (localName == null) {
  1000. coyoteRequest.action
  1001. (ActionCode.ACTION_REQ_LOCAL_NAME_ATTRIBUTE, coyoteRequest);
  1002. localName = coyoteRequest.localName().toString();
  1003. }
  1004. return localName;
  1005. }
  1006. /**
  1007. * Returns the Internet Protocol (IP) address of the interface on
  1008. * which the request was received.
  1009. */
  1010. public String getLocalAddr(){
  1011. if (localAddr == null) {
  1012. coyoteRequest.action
  1013. (ActionCode.ACTION_REQ_LOCAL_ADDR_ATTRIBUTE, coyoteRequest);
  1014. localAddr = coyoteRequest.localAddr().toString();
  1015. }
  1016. return localAddr;
  1017. }
  1018. /**
  1019. * Returns the Internet Protocol (IP) port number of the interface
  1020. * on which the request was received.
  1021. */
  1022. public int getLocalPort(){
  1023. if (localPort == -1){
  1024. coyoteRequest.action
  1025. (ActionCode.ACTION_REQ_LOCALPORT_ATTRIBUTE, coyoteRequest);
  1026. localPort = coyoteRequest.getLocalPort();
  1027. }
  1028. return localPort;
  1029. }
  1030. /**
  1031. * Return a RequestDispatcher that wraps the resource at the specified
  1032. * path, which may be interpreted as relative to the current request path.
  1033. *
  1034. * @param path Path of the resource to be wrapped
  1035. */
  1036. public RequestDispatcher getRequestDispatcher(String path) {
  1037. if (context == null)
  1038. return null;
  1039. // If the path is already context-relative, just pass it through
  1040. if (path == null)
  1041. return null;
  1042. else if (path.startsWith("/"))
  1043. return (context.getServletContext().getRequestDispatcher(path));
  1044. // Convert a request-relative path to a context-relative one
  1045. String servletPath = (String) getAttribute(Globals.INCLUDE_SERVLET_PATH_ATTR);
  1046. if (servletPath == null)
  1047. servletPath = getServletPath();
  1048. // Add the path info, if there is any
  1049. String pathInfo = getPathInfo();
  1050. String requestPath = null;
  1051. if (pathInfo == null) {
  1052. requestPath = servletPath;
  1053. } else {
  1054. requestPath = servletPath + pathInfo;
  1055. }
  1056. int pos = requestPath.lastIndexOf('/');
  1057. String relative = null;
  1058. if (pos >= 0) {
  1059. relative = requestPath.substring(0, pos + 1) + path;
  1060. } else {
  1061. relative = requestPath + path;
  1062. }
  1063. return context.getServletContext().getRequestDispatcher(relative);
  1064. }
  1065. /**
  1066. * Return the scheme used to make this Request.
  1067. */
  1068. public String getScheme() {
  1069. return coyoteRequest.scheme().toString();
  1070. }
  1071. /**
  1072. * Return the server name responding to this Request.
  1073. */
  1074. public String getServerName() {
  1075. return coyoteRequest.serverName().toString();
  1076. }
  1077. /**
  1078. * Return the server port responding to this Request.
  1079. */
  1080. public int getServerPort() {
  1081. return coyoteRequest.getServerPort();
  1082. }
  1083. /**
  1084. * Was this request received on a secure connection?
  1085. */
  1086. public boolean isSecure() {
  1087. return secure;
  1088. }
  1089. /**
  1090. * Remove the specified request attribute if it exists.
  1091. *
  1092. * @param name Name of the request attribute to remove
  1093. */
  1094. public void removeAttribute(String name) {
  1095. Object value = null;
  1096. boolean found = false;
  1097. // Remove the specified attribute
  1098. // Check for read only attribute
  1099. // requests are per thread so synchronization unnecessary
  1100. if (readOnlyAttributes.containsKey(name)) {
  1101. return;
  1102. }
  1103. // Pass special attributes to the native layer
  1104. if (name.startsWith("org.apache.tomcat.")) {
  1105. coyoteRequest.getAttributes().remove(name);
  1106. }
  1107. found = attributes.containsKey(name);
  1108. if (found) {
  1109. value = attributes.get(name);
  1110. attributes.remove(name);
  1111. } else {
  1112. return;
  1113. }
  1114. // Notify interested application event listeners
  1115. Object listeners[] = context.getApplicationEventListeners();
  1116. if ((listeners == null) || (listeners.length == 0))
  1117. return;
  1118. ServletRequestAttributeEvent event =
  1119. new ServletRequestAttributeEvent(context.getServletContext(),
  1120. getRequest(), name, value);
  1121. for (int i = 0; i < listeners.length; i++) {
  1122. if (!(listeners[i] instanceof ServletRequestAttributeListener))
  1123. continue;
  1124. ServletRequestAttributeListener listener =
  1125. (ServletRequestAttributeListener) listeners[i];
  1126. try {
  1127. listener.attributeRemoved(event);
  1128. } catch (Throwable t) {
  1129. context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
  1130. // Error valve will pick this exception up and display it to user
  1131. attributes.put( Globals.EXCEPTION_ATTR, t );
  1132. }
  1133. }
  1134. }
  1135. /**
  1136. * Set the specified request attribute to the specified value.
  1137. *
  1138. * @param name Name of the request attribute to set
  1139. * @param value The associated value
  1140. */
  1141. public void setAttribute(String name, Object value) {
  1142. // Name cannot be null
  1143. if (name == null)
  1144. throw new IllegalArgumentException
  1145. (sm.getString("coyoteRequest.setAttribute.namenull"));
  1146. // Null value is the same as removeAttribute()
  1147. if (value == null) {
  1148. removeAttribute(name);
  1149. return;
  1150. }
  1151. if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
  1152. internalDispatcherType = (DispatcherType)value;
  1153. return;
  1154. } else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
  1155. requestDispatcherPath = value;
  1156. return;
  1157. }
  1158. if (name.equals(Globals.ASYNC_SUPPORTED_ATTR)) {
  1159. this.asyncSupported = (Boolean)value;
  1160. }
  1161. Object oldValue = null;
  1162. boolean replaced = false;
  1163. // Add or replace the specified attribute
  1164. // Check for read only attribute
  1165. // requests are per thread so synchronization unnecessary
  1166. if (readOnlyAttributes.containsKey(name)) {
  1167. return;
  1168. }
  1169. oldValue = attributes.put(name, value);
  1170. if (oldValue != null) {
  1171. replaced = true;
  1172. }
  1173. // Pass special attributes to the native layer
  1174. if (name.startsWith("org.apache.tomcat.")) {
  1175. coyoteRequest.setAttribute(name, value);
  1176. }
  1177. // Notify interested application event listeners
  1178. Object listeners[] = context.getApplicationEventListeners();
  1179. if ((listeners == null) || (listeners.length == 0))
  1180. return;
  1181. ServletRequestAttributeEvent event = null;
  1182. if (replaced)
  1183. event =
  1184. new ServletRequestAttributeEvent(context.getServletContext(),
  1185. getRequest(), name, oldValue);
  1186. else
  1187. event =
  1188. new ServletRequestAttributeEvent(context.getServletContext(),
  1189. getRequest(), name, value);
  1190. for (int i = 0; i < listeners.length; i++) {
  1191. if (!(listeners[i] instanceof ServletRequestAttributeListener))
  1192. continue;
  1193. ServletRequestAttributeListener listener =
  1194. (ServletRequestAttributeListener) listeners[i];
  1195. try {
  1196. if (replaced) {
  1197. listener.attributeReplaced(event);
  1198. } else {
  1199. listener.attributeAdded(event);
  1200. }
  1201. } catch (Throwable t) {
  1202. context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
  1203. // Error valve will pick this exception up and display it to user
  1204. attributes.put( Globals.EXCEPTION_ATTR, t );
  1205. }
  1206. }
  1207. }
  1208. /**
  1209. * Overrides the name of the character encoding used in the body of
  1210. * this request. This method must be called prior to reading request
  1211. * parameters or reading input using <code>getReader()</code>.
  1212. *
  1213. * @param enc The character encoding to be used
  1214. *
  1215. * @exception UnsupportedEncodingException if the specified encoding
  1216. * is not supported
  1217. *
  1218. * @since Servlet 2.3
  1219. */
  1220. public void setCharacterEncoding(String enc)
  1221. throws UnsupportedEncodingException {
  1222. if (usingReader)
  1223. return;
  1224. // Ensure that the specified encoding is valid
  1225. byte buffer[] = new byte[1];
  1226. buffer[0] = (byte) 'a';
  1227. new String(buffer, enc);
  1228. // Save the validated encoding
  1229. coyoteRequest.setCharacterEncoding(enc);
  1230. }
  1231. public ServletContext getServletContext() {
  1232. return context.getServletContext();
  1233. }
  1234. public AsyncContext startAsync() {
  1235. return startAsync(getRequest(),response.getResponse());
  1236. }
  1237. public AsyncContext startAsync(ServletRequest request,
  1238. ServletResponse response) {
  1239. if (!isAsyncSupported()) {
  1240. throw new IllegalStateException("Not supported.");
  1241. }
  1242. if (asyncContext==null) {
  1243. asyncContext = new AsyncContextImpl(this);
  1244. } else if (asyncContext.isStarted()) {
  1245. throw new IllegalStateException("Already started.");
  1246. }
  1247. asyncContext.setStarted(getContext());
  1248. asyncContext.init(request,response);
  1249. asyncContext.setHasOriginalRequestAndResponse(request==getRequest() &&
  1250. response==getResponse().getResponse());
  1251. asyncContext.setTimeout(getConnector().getAsyncTimeout());
  1252. return asyncContext;
  1253. }
  1254. public boolean isAsyncStarted() {
  1255. if (asyncContext == null) {
  1256. return false;
  1257. }
  1258. return asyncContext.isStarted();
  1259. }
  1260. public boolean isAsyncDispatching() {
  1261. if (asyncContext == null) {
  1262. return false;
  1263. }
  1264. return (asyncContext.getState()==AsyncContextImpl.AsyncState.DISPATCHING ||
  1265. asyncContext.getState()==AsyncContextImpl.AsyncState.TIMING_OUT ||
  1266. asyncContext.getState()==AsyncContextImpl.AsyncState.STARTED ||
  1267. asyncContext.getState()==AsyncContextImpl.AsyncState.ERROR_DISPATCHING ||
  1268. asyncContext.getState()==AsyncContextImpl.AsyncState.COMPLETING);
  1269. }
  1270. public boolean isAsyncSupported() {
  1271. if (this.asyncSupported == null) {
  1272. return true;
  1273. }
  1274. return asyncSupported.booleanValue();
  1275. }
  1276. public AsyncContext getAsyncContext() {
  1277. return this.asyncContext;
  1278. }
  1279. public DispatcherType getDispatcherType() {
  1280. if (internalDispatcherType == null) {
  1281. return DispatcherType.REQUEST;
  1282. }
  1283. return this.internalDispatcherType;
  1284. }
  1285. // ---------------------------------------------------- HttpRequest Methods
  1286. /**
  1287. * Add a Cookie to the set of Cookies associated with this Request.
  1288. *
  1289. * @param cookie The new cookie
  1290. */
  1291. public void addCookie(Cookie cookie) {
  1292. if (!cookiesParsed)
  1293. parseCookies();
  1294. int size = 0;
  1295. if (cookies != null) {
  1296. size = cookies.length;
  1297. }
  1298. Cookie[] newCookies = new Cookie[size + 1];
  1299. for (int i = 0; i < size; i++) {
  1300. newCookies[i] = cookies[i];
  1301. }
  1302. newCookies[size] = cookie;
  1303. cookies = newCookies;
  1304. }
  1305. /**
  1306. * Add a Locale to the set of preferred Locales for this Request. The
  1307. * first added Locale will be the first one returned by getLocales().
  1308. *
  1309. * @param locale The new preferred Locale
  1310. */
  1311. public void addLocale(Locale locale) {
  1312. locales.add(locale);
  1313. }
  1314. /**
  1315. * Add a parameter name and corresponding set of values to this Request.
  1316. * (This is used when restoring the original request on a form based
  1317. * login).
  1318. *
  1319. * @param name Name of this request parameter
  1320. * @param values Corresponding values for this request parameter
  1321. */
  1322. public void addParameter(String name, String values[]) {
  1323. coyoteRequest.getParameters().addParameterValues(name, values);
  1324. }
  1325. /**
  1326. * Clear the collection of Cookies associated with this Request.
  1327. */
  1328. public void clearCookies() {
  1329. cookiesParsed = true;
  1330. cookies = null;
  1331. }
  1332. /**
  1333. * Clear the collection of Headers associated with this Request.
  1334. */
  1335. public void clearHeaders() {
  1336. // Not used
  1337. }
  1338. /**
  1339. * Clear the collection of Locales associated with this Request.
  1340. */
  1341. public void clearLocales() {
  1342. locales.clear();
  1343. }
  1344. /**
  1345. * Clear the collection of parameters associated with this Request.
  1346. */
  1347. public void clearParameters() {
  1348. // Not used
  1349. }
  1350. /**
  1351. * Set the authentication type used for this request, if any; otherwise
  1352. * set the type to <code>null</code>. Typical values are "BASIC",
  1353. * "DIGEST", or "SSL".
  1354. *
  1355. * @param type The authentication type used
  1356. */
  1357. public void setAuthType(String type) {
  1358. this.authType = type;
  1359. }
  1360. /**
  1361. * Set the context path for this Request. This will normally be called
  1362. * when the associated Context is mapping the Request to a particular
  1363. * Wrapper.
  1364. *
  1365. * @param path The context path
  1366. */
  1367. public void setContextPath(String path) {
  1368. if (path == null) {
  1369. mappingData.contextPath.setString("");
  1370. } else {
  1371. mappingData.contextPath.setString(path);
  1372. }
  1373. }
  1374. /**
  1375. * Set the path information for this Request. This will normally be called
  1376. * when the associated Context is mapping the Request to a particular
  1377. * Wrapper.
  1378. *
  1379. * @param path The path information
  1380. */
  1381. public void setPathInfo(String path) {
  1382. mappingData.pathInfo.setString(path);
  1383. }
  1384. /**
  1385. * Set a flag indicating whether or not the requested session ID for this
  1386. * request came in through a cookie. This is normally called by the
  1387. * HTTP Connector, when it parses the request headers.
  1388. *
  1389. * @param flag The new flag
  1390. */
  1391. public void setRequestedSessionCookie(boolean flag) {
  1392. this.requestedSessionCookie = flag;
  1393. }
  1394. /**
  1395. * Set the requested session ID for this request. This is normally called
  1396. * by the HTTP Connector, when it parses the request headers.
  1397. *
  1398. * @param id The new session id
  1399. */
  1400. public void setRequestedSessionId(String id) {
  1401. this.requestedSessionId = id;
  1402. }
  1403. /**
  1404. * Set a flag indicating whether or not the requested session ID for this
  1405. * request came in through a URL. This is normally called by the
  1406. * HTTP Connector, when it parses the request headers.
  1407. *
  1408. * @param flag The new flag
  1409. */
  1410. public void setRequestedSessionURL(boolean flag) {
  1411. this.requestedSessionURL = flag;
  1412. }
  1413. /**
  1414. * Set a flag indicating whether or not the requested session ID for this
  1415. * request came in through SSL. This is normally called by the
  1416. * HTTP Connector, when it parses the request headers.
  1417. *
  1418. * @param flag The new flag
  1419. */
  1420. public void setRequestedSessionSSL(boolean flag) {
  1421. this.requestedSessionSSL = flag;
  1422. }
  1423. /**
  1424. * Get the decoded request URI.
  1425. *
  1426. * @return the URL decoded request URI
  1427. */
  1428. public String getDecodedRequestURI() {
  1429. return coyoteRequest.decodedURI().toString();
  1430. }
  1431. /**
  1432. * Get the decoded request URI.
  1433. *
  1434. * @return the URL decoded request URI
  1435. */
  1436. public MessageBytes getDecodedRequestURIMB() {
  1437. return co