KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > connector > Request


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
18
19 package org.apache.catalina.connector;
20
21
22 import java.io.InputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.io.BufferedReader JavaDoc;
25 import java.io.UnsupportedEncodingException JavaDoc;
26 import java.security.Principal JavaDoc;
27 import java.text.SimpleDateFormat JavaDoc;
28 import java.util.ArrayList JavaDoc;
29 import java.util.Enumeration JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import java.util.Locale JavaDoc;
33 import java.util.Map JavaDoc;
34 import java.util.TimeZone JavaDoc;
35 import java.util.TreeMap JavaDoc;
36
37 import javax.security.auth.Subject JavaDoc;
38 import javax.servlet.FilterChain JavaDoc;
39 import javax.servlet.RequestDispatcher JavaDoc;
40 import javax.servlet.ServletContext JavaDoc;
41 import javax.servlet.ServletInputStream JavaDoc;
42 import javax.servlet.ServletRequestAttributeEvent JavaDoc;
43 import javax.servlet.ServletRequestAttributeListener JavaDoc;
44 import javax.servlet.http.Cookie JavaDoc;
45 import javax.servlet.http.HttpServletRequest JavaDoc;
46 import javax.servlet.http.HttpSession JavaDoc;
47
48 import org.apache.tomcat.util.buf.B2CConverter;
49 import org.apache.tomcat.util.buf.MessageBytes;
50 import org.apache.tomcat.util.buf.StringCache;
51 import org.apache.tomcat.util.http.Cookies;
52 import org.apache.tomcat.util.http.FastHttpDateFormat;
53 import org.apache.tomcat.util.http.Parameters;
54 import org.apache.tomcat.util.http.ServerCookie;
55 import org.apache.tomcat.util.http.mapper.MappingData;
56
57 import org.apache.coyote.ActionCode;
58
59 import org.apache.catalina.Context;
60 import org.apache.catalina.Globals;
61 import org.apache.catalina.Host;
62 import org.apache.catalina.Manager;
63 import org.apache.catalina.Realm;
64 import org.apache.catalina.Session;
65 import org.apache.catalina.Wrapper;
66 import org.apache.catalina.core.ApplicationFilterFactory;
67 import org.apache.catalina.realm.GenericPrincipal;
68 import org.apache.catalina.util.Enumerator;
69 import org.apache.catalina.util.ParameterMap;
70 import org.apache.catalina.util.RequestUtil;
71 import org.apache.catalina.util.StringManager;
72 import org.apache.catalina.util.StringParser;
73
74
75 /**
76  * Wrapper object for the Coyote request.
77  *
78  * @author Remy Maucherat
79  * @author Craig R. McClanahan
80  * @version $Revision: 470756 $ $Date: 2006-11-03 11:56:25 +0100 (ven., 03 nov. 2006) $
81  */

82
83 public class Request
84     implements HttpServletRequest JavaDoc {
85
86
87     // ----------------------------------------------------------- Constructors
88

89
90     static {
91         // Ensure that classes are loaded for SM
92
new StringCache.ByteEntry();
93         new StringCache.CharEntry();
94     }
95
96     public Request() {
97
98         formats[0].setTimeZone(GMT_ZONE);
99         formats[1].setTimeZone(GMT_ZONE);
100         formats[2].setTimeZone(GMT_ZONE);
101
102     }
103
104
105     // ------------------------------------------------------------- Properties
106

107
108     /**
109      * Coyote request.
110      */

111     protected org.apache.coyote.Request coyoteRequest;
112
113     /**
114      * Set the Coyote request.
115      *
116      * @param coyoteRequest The Coyote request
117      */

118     public void setCoyoteRequest(org.apache.coyote.Request coyoteRequest) {
119         this.coyoteRequest = coyoteRequest;
120         inputBuffer.setRequest(coyoteRequest);
121     }
122
123     /**
124      * Get the Coyote request.
125      */

126     public org.apache.coyote.Request getCoyoteRequest() {
127         return (this.coyoteRequest);
128     }
129
130
131     // ----------------------------------------------------- Variables
132

133
134     protected static final TimeZone JavaDoc GMT_ZONE = TimeZone.getTimeZone("GMT");
135
136
137     /**
138      * The string manager for this package.
139      */

140     protected static StringManager sm =
141         StringManager.getManager(Constants.Package);
142
143
144     /**
145      * The set of cookies associated with this Request.
146      */

147     protected Cookie JavaDoc[] cookies = null;
148
149
150     /**
151      * The set of SimpleDateFormat formats to use in getDateHeader().
152      *
153      * Notice that because SimpleDateFormat is not thread-safe, we can't
154      * declare formats[] as a static variable.
155      */

156     protected SimpleDateFormat JavaDoc formats[] = {
157         new SimpleDateFormat JavaDoc("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
158         new SimpleDateFormat JavaDoc("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
159         new SimpleDateFormat JavaDoc("EEE MMMM d HH:mm:ss yyyy", Locale.US)
160     };
161
162
163     /**
164      * The default Locale if none are specified.
165      */

166     protected static Locale JavaDoc defaultLocale = Locale.getDefault();
167
168
169     /**
170      * The attributes associated with this Request, keyed by attribute name.
171      */

172     protected HashMap JavaDoc attributes = new HashMap JavaDoc();
173
174
175     /**
176      * List of read only attributes for this Request.
177      */

178     private HashMap JavaDoc readOnlyAttributes = new HashMap JavaDoc();
179
180
181     /**
182      * The preferred Locales assocaited with this Request.
183      */

184     protected ArrayList JavaDoc locales = new ArrayList JavaDoc();
185
186
187     /**
188      * Internal notes associated with this request by Catalina components
189      * and event listeners.
190      */

191     private transient HashMap JavaDoc notes = new HashMap JavaDoc();
192
193
194     /**
195      * Authentication type.
196      */

197     protected String JavaDoc authType = null;
198
199     
200     /**
201      * Associated event.
202      */

203     protected CometEventImpl event = null;
204     
205
206     /**
207      * Comet state
208      */

209     protected boolean comet = false;
210     
211     
212     /**
213      * The current dispatcher type.
214      */

215     protected Object JavaDoc dispatcherType = null;
216
217
218     /**
219      * The associated input buffer.
220      */

221     protected InputBuffer inputBuffer = new InputBuffer();
222
223
224     /**
225      * ServletInputStream.
226      */

227     protected CoyoteInputStream inputStream =
228         new CoyoteInputStream(inputBuffer);
229
230
231     /**
232      * Reader.
233      */

234     protected CoyoteReader reader = new CoyoteReader(inputBuffer);
235
236
237     /**
238      * Using stream flag.
239      */

240     protected boolean usingInputStream = false;
241
242
243     /**
244      * Using writer flag.
245      */

246     protected boolean usingReader = false;
247
248
249     /**
250      * User principal.
251      */

252     protected Principal JavaDoc userPrincipal = null;
253
254
255     /**
256      * Session parsed flag.
257      */

258     protected boolean sessionParsed = false;
259
260
261     /**
262      * Request parameters parsed flag.
263      */

264     protected boolean parametersParsed = false;
265
266
267     /**
268      * Cookies parsed flag.
269      */

270     protected boolean cookiesParsed = false;
271
272
273     /**
274      * Secure flag.
275      */

276     protected boolean secure = false;
277
278     
279     /**
280      * The Subject associated with the current AccessControllerContext
281      */

282     protected transient Subject JavaDoc subject = null;
283
284
285     /**
286      * Post data buffer.
287      */

288     protected static int CACHED_POST_LEN = 8192;
289     protected byte[] postData = null;
290
291
292     /**
293      * Hash map used in the getParametersMap method.
294      */

295     protected ParameterMap parameterMap = new ParameterMap();
296
297
298     /**
299      * The currently active session for this request.
300      */

301     protected Session JavaDoc session = null;
302
303
304     /**
305      * The current request dispatcher path.
306      */

307     protected Object JavaDoc requestDispatcherPath = null;
308
309
310     /**
311      * Was the requested session ID received in a cookie?
312      */

313     protected boolean requestedSessionCookie = false;
314
315
316     /**
317      * The requested session ID (if any) for this request.
318      */

319     protected String JavaDoc requestedSessionId = null;
320
321
322     /**
323      * Was the requested session ID received in a URL?
324      */

325     protected boolean requestedSessionURL = false;
326
327
328     /**
329      * Parse locales.
330      */

331     protected boolean localesParsed = false;
332
333
334     /**
335      * The string parser we will use for parsing request lines.
336      */

337     private StringParser parser = new StringParser();
338
339
340     /**
341      * Local port
342      */

343     protected int localPort = -1;
344
345     /**
346      * Remote address.
347      */

348     protected String JavaDoc remoteAddr = null;
349
350
351     /**
352      * Remote host.
353      */

354     protected String JavaDoc remoteHost = null;
355
356     
357     /**
358      * Remote port
359      */

360     protected int remotePort = -1;
361     
362     /**
363      * Local address
364      */

365     protected String JavaDoc localAddr = null;
366
367     
368     /**
369      * Local address
370      */

371     protected String JavaDoc localName = null;
372
373
374     // --------------------------------------------------------- Public Methods
375

376
377     /**
378      * Release all object references, and initialize instance variables, in
379      * preparation for reuse of this object.
380      */

381     public void recycle() {
382
383         context = null;
384         wrapper = null;
385
386         dispatcherType = null;
387         requestDispatcherPath = null;
388
389         comet = false;
390         if (event != null) {
391             event.clear();
392             event = null;
393         }
394         
395         authType = null;
396         inputBuffer.recycle();
397         usingInputStream = false;
398         usingReader = false;
399         userPrincipal = null;
400         subject = null;
401         sessionParsed = false;
402         parametersParsed = false;
403         cookiesParsed = false;
404         locales.clear();
405         localesParsed = false;
406         secure = false;
407         remoteAddr = null;
408         remoteHost = null;
409         remotePort = -1;
410         localPort = -1;
411         localAddr = null;
412         localName = null;
413
414         attributes.clear();
415         notes.clear();
416         cookies = null;
417
418         if (session != null) {
419             session.endAccess();
420         }
421         session = null;
422         requestedSessionCookie = false;
423         requestedSessionId = null;
424         requestedSessionURL = false;
425
426         if (Constants.SECURITY || Connector.RECYCLE_FACADES) {
427             parameterMap = new ParameterMap();
428         } else {
429             parameterMap.setLocked(false);
430             parameterMap.clear();
431         }
432
433         mappingData.recycle();
434
435         if (Constants.SECURITY || Connector.RECYCLE_FACADES) {
436             if (facade != null) {
437                 facade.clear();
438                 facade = null;
439             }
440             if (inputStream != null) {
441                 inputStream.clear();
442                 inputStream = null;
443             }
444             if (reader != null) {
445                 reader.clear();
446                 reader = null;
447             }
448         }
449
450     }
451
452
453     /**
454      * Clear cached encoders (to save memory for Comet requests).
455      */

456     public void clearEncoders() {
457         inputBuffer.clearEncoders();
458     }
459     
460
461     // -------------------------------------------------------- Request Methods
462

463
464     /**
465      * Associated Catalina connector.
466      */

467     protected Connector connector;
468
469     /**
470      * Return the Connector through which this Request was received.
471      */

472     public Connector getConnector() {
473         return (this.connector);
474     }
475
476     /**
477      * Set the Connector through which this Request was received.
478      *
479      * @param connector The new connector
480      */

481     public void setConnector(Connector connector) {
482         this.connector = connector;
483     }
484
485
486     /**
487      * Associated context.
488      */

489     protected Context JavaDoc context = null;
490
491     /**
492      * Return the Context within which this Request is being processed.
493      */

494     public Context JavaDoc getContext() {
495         return (this.context);
496     }
497
498
499     /**
500      * Set the Context within which this Request is being processed. This
501      * must be called as soon as the appropriate Context is identified, because
502      * it identifies the value to be returned by <code>getContextPath()</code>,
503      * and thus enables parsing of the request URI.
504      *
505      * @param context The newly associated Context
506      */

507     public void setContext(Context JavaDoc context) {
508         this.context = context;
509     }
510
511
512     /**
513      * Filter chain associated with the request.
514      */

515     protected FilterChain JavaDoc filterChain = null;
516
517     /**
518      * Get filter chain associated with the request.
519      */

520     public FilterChain JavaDoc getFilterChain() {
521         return (this.filterChain);
522     }
523
524     /**
525      * Set filter chain associated with the request.
526      *
527      * @param filterChain new filter chain
528      */

529     public void setFilterChain(FilterChain JavaDoc filterChain) {
530         this.filterChain = filterChain;
531     }
532
533
534     /**
535      * Return the Host within which this Request is being processed.
536      */

537     public Host getHost() {
538         if (getContext() == null)
539             return null;
540         return (Host) getContext().getParent();
541         //return ((Host) mappingData.host);
542
}
543
544
545     /**
546      * Set the Host within which this Request is being processed. This
547      * must be called as soon as the appropriate Host is identified, and
548      * before the Request is passed to a context.
549      *
550      * @param host The newly associated Host
551      */

552     public void setHost(Host host) {
553         mappingData.host = host;
554     }
555
556
557     /**
558      * Descriptive information about this Request implementation.
559      */

560     protected static final String JavaDoc info =
561         "org.apache.coyote.catalina.CoyoteRequest/1.0";
562
563     /**
564      * Return descriptive information about this Request implementation and
565      * the corresponding version number, in the format
566      * <code>&lt;description&gt;/&lt;version&gt;</code>.
567      */

568     public String JavaDoc getInfo() {
569         return (info);
570     }
571
572
573     /**
574      * Mapping data.
575      */

576     protected MappingData mappingData = new MappingData();
577
578     /**
579      * Return mapping data.
580      */

581     public MappingData getMappingData() {
582         return (mappingData);
583     }
584
585
586     /**
587      * The facade associated with this request.
588      */

589     protected RequestFacade facade = null;
590
591     /**
592      * Return the <code>ServletRequest</code> for which this object
593      * is the facade. This method must be implemented by a subclass.
594      */

595     public HttpServletRequest JavaDoc getRequest() {
596         if (facade == null) {
597             facade = new RequestFacade(this);
598         }
599         return (facade);
600     }
601
602
603     /**
604      * The response with which this request is associated.
605      */

606     protected org.apache.catalina.connector.Response response = null;
607
608     /**
609      * Return the Response with which this Request is associated.
610      */

611     public org.apache.catalina.connector.Response getResponse() {
612         return (this.response);
613     }
614
615     /**
616      * Set the Response with which this Request is associated.
617      *
618      * @param response The new associated response
619      */

620     public void setResponse(org.apache.catalina.connector.Response response) {
621         this.response = response;
622     }
623
624     /**
625      * Return the input stream associated with this Request.
626      */

627     public InputStream JavaDoc getStream() {
628         if (inputStream == null) {
629             inputStream = new CoyoteInputStream(inputBuffer);
630         }
631         return inputStream;
632     }
633
634     /**
635      * Set the input stream associated with this Request.
636      *
637      * @param stream The new input stream
638      */

639     public void setStream(InputStream JavaDoc stream) {
640         // Ignore
641
}
642
643
644     /**
645      * URI byte to char converter (not recycled).
646      */

647     protected B2CConverter URIConverter = null;
648
649     /**
650      * Return the URI converter.
651      */

652     protected B2CConverter getURIConverter() {
653         return URIConverter;
654     }
655
656     /**
657      * Set the URI converter.
658      *
659      * @param URIConverter the new URI connverter
660      */

661     protected void setURIConverter(B2CConverter URIConverter) {
662         this.URIConverter = URIConverter;
663     }
664
665
666     /**
667      * Associated wrapper.
668      */

669     protected Wrapper wrapper = null;
670
671     /**
672      * Return the Wrapper within which this Request is being processed.
673      */

674     public Wrapper getWrapper() {
675         return (this.wrapper);
676     }
677
678
679     /**
680      * Set the Wrapper within which this Request is being processed. This
681      * must be called as soon as the appropriate Wrapper is identified, and
682      * before the Request is ultimately passed to an application servlet.
683      * @param wrapper The newly associated Wrapper
684      */

685     public void setWrapper(Wrapper wrapper) {
686         this.wrapper = wrapper;
687     }
688
689
690     // ------------------------------------------------- Request Public Methods
691

692
693     /**
694      * Create and return a ServletInputStream to read the content
695      * associated with this Request.
696      *
697      * @exception IOException if an input/output error occurs
698      */

699     public ServletInputStream JavaDoc createInputStream()
700         throws IOException JavaDoc {
701         if (inputStream == null) {
702             inputStream = new CoyoteInputStream(inputBuffer);
703         }
704         return inputStream;
705     }
706
707
708     /**
709      * Perform whatever actions are required to flush and close the input
710      * stream or reader, in a single operation.
711      *
712      * @exception IOException if an input/output error occurs
713      */

714     public void finishRequest() throws IOException JavaDoc {
715         // The reader and input stream don't need to be closed
716
}
717
718
719     /**
720      * Return the object bound with the specified name to the internal notes
721      * for this request, or <code>null</code> if no such binding exists.
722      *
723      * @param name Name of the note to be returned
724      */

725     public Object JavaDoc getNote(String JavaDoc name) {
726         return (notes.get(name));
727     }
728
729
730     /**
731      * Return an Iterator containing the String names of all notes bindings
732      * that exist for this request.
733      */

734     public Iterator JavaDoc getNoteNames() {
735         return (notes.keySet().iterator());
736     }
737
738
739     /**
740      * Remove any object bound to the specified name in the internal notes
741      * for this request.
742      *
743      * @param name Name of the note to be removed
744      */

745     public void removeNote(String JavaDoc name) {
746         notes.remove(name);
747     }
748
749
750     /**
751      * Bind an object to a specified name in the internal notes associated
752      * with this request, replacing any existing binding for this name.
753      *
754      * @param name Name to which the object should be bound
755      * @param value Object to be bound to the specified name
756      */

757     public void setNote(String JavaDoc name, Object JavaDoc value) {
758         notes.put(name, value);
759     }
760
761
762     /**
763      * Set the content length associated with this Request.
764      *
765      * @param length The new content length
766      */

767     public void setContentLength(int length) {
768         // Not used
769
}
770
771
772     /**
773      * Set the content type (and optionally the character encoding)
774      * associated with this Request. For example,
775      * <code>text/html; charset=ISO-8859-4</code>.
776      *
777      * @param type The new content type
778      */

779     public void setContentType(String JavaDoc type) {
780         // Not used
781
}
782
783
784     /**
785      * Set the protocol name and version associated with this Request.
786      *
787      * @param protocol Protocol name and version
788      */

789     public void setProtocol(String JavaDoc protocol) {
790         // Not used
791
}
792
793
794     /**
795      * Set the IP address of the remote client associated with this Request.
796      *
797      * @param remoteAddr The remote IP address
798      */

799     public void setRemoteAddr(String JavaDoc remoteAddr) {
800         // Not used
801
}
802
803
804     /**
805      * Set the fully qualified name of the remote client associated with this
806      * Request.
807      *
808      * @param remoteHost The remote host name
809      */

810     public void setRemoteHost(String JavaDoc remoteHost) {
811         // Not used
812
}
813
814
815     /**
816      * Set the name of the scheme associated with this request. Typical values
817      * are <code>http</code>, <code>https</code>, and <code>ftp</code>.
818      *
819      * @param scheme The scheme
820      */

821     public void setScheme(String JavaDoc scheme) {
822         // Not used
823
}
824
825
826     /**
827      * Set the value to be returned by <code>isSecure()</code>
828      * for this Request.
829      *
830      * @param secure The new isSecure value
831      */

832     public void setSecure(boolean secure) {
833         this.secure = secure;
834     }
835
836
837     /**
838      * Set the name of the server (virtual host) to process this request.
839      *
840      * @param name The server name
841      */

842     public void setServerName(String JavaDoc name) {
843         coyoteRequest.serverName().setString(name);
844     }
845
846
847     /**
848      * Set the port number of the server to process this request.
849      *
850      * @param port The server port
851      */

852     public void setServerPort(int port) {
853         coyoteRequest.setServerPort(port);
854     }
855
856
857     // ------------------------------------------------- ServletRequest Methods
858

859
860     /**
861      * Return the specified request attribute if it exists; otherwise, return
862      * <code>null</code>.
863      *
864      * @param name Name of the request attribute to return
865      */

866     public Object JavaDoc getAttribute(String JavaDoc name) {
867
868         if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
869             return (dispatcherType == null)
870                 ? ApplicationFilterFactory.REQUEST_INTEGER
871                 : dispatcherType;
872         } else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
873             return (requestDispatcherPath == null)
874                 ? getRequestPathMB().toString()
875                 : requestDispatcherPath.toString();
876         }
877
878         Object JavaDoc attr=attributes.get(name);
879
880         if(attr!=null)
881             return(attr);
882
883         attr = coyoteRequest.getAttribute(name);
884         if(attr != null)
885             return attr;
886         if( isSSLAttribute(name) ) {
887             coyoteRequest.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,
888                                  coyoteRequest);
889             attr = coyoteRequest.getAttribute(Globals.CERTIFICATES_ATTR);
890             if( attr != null) {
891                 attributes.put(Globals.CERTIFICATES_ATTR, attr);
892             }
893             attr = coyoteRequest.getAttribute(Globals.CIPHER_SUITE_ATTR);
894             if(attr != null) {
895                 attributes.put(Globals.CIPHER_SUITE_ATTR, attr);
896             }
897             attr = coyoteRequest.getAttribute(Globals.KEY_SIZE_ATTR);
898             if(attr != null) {
899                 attributes.put(Globals.KEY_SIZE_ATTR, attr);
900             }
901             attr = coyoteRequest.getAttribute(Globals.SSL_SESSION_ID_ATTR);
902             if(attr != null) {
903                 attributes.put(Globals.SSL_SESSION_ID_ATTR, attr);
904             }
905             attr = attributes.get(name);
906         }
907         return attr;
908     }
909
910
911     /**
912      * Test if a given name is one of the special Servlet-spec SSL attributes.
913      */

914     static boolean isSSLAttribute(String JavaDoc name) {
915         return Globals.CERTIFICATES_ATTR.equals(name) ||
916             Globals.CIPHER_SUITE_ATTR.equals(name) ||
917             Globals.KEY_SIZE_ATTR.equals(name) ||
918             Globals.SSL_SESSION_ID_ATTR.equals(name);
919     }
920
921     /**
922      * Return the names of all request attributes for this Request, or an
923      * empty <code>Enumeration</code> if there are none.
924      */

925     public Enumeration JavaDoc getAttributeNames() {
926         if (isSecure()) {
927             getAttribute(Globals.CERTIFICATES_ATTR);
928         }
929         return new Enumerator(attributes.keySet(), true);
930     }
931
932
933     /**
934      * Return the character encoding for this Request.
935      */

936     public String JavaDoc getCharacterEncoding() {
937       return (coyoteRequest.getCharacterEncoding());
938     }
939
940
941     /**
942      * Return the content length for this Request.
943      */

944     public int getContentLength() {
945         return (coyoteRequest.getContentLength());
946     }
947
948
949     /**
950      * Return the content type for this Request.
951      */

952     public String JavaDoc getContentType() {
953         return (coyoteRequest.getContentType());
954     }
955
956
957     /**
958      * Return the servlet input stream for this Request. The default
959      * implementation returns a servlet input stream created by
960      * <code>createInputStream()</code>.
961      *
962      * @exception IllegalStateException if <code>getReader()</code> has
963      * already been called for this request
964      * @exception IOException if an input/output error occurs
965      */

966     public ServletInputStream JavaDoc getInputStream() throws IOException JavaDoc {
967
968         if (usingReader)
969             throw new IllegalStateException JavaDoc
970                 (sm.getString("coyoteRequest.getInputStream.ise"));
971
972         usingInputStream = true;
973         if (inputStream == null) {
974             inputStream = new CoyoteInputStream(inputBuffer);
975         }
976         return inputStream;
977
978     }
979
980
981     /**
982      * Return the preferred Locale that the client will accept content in,
983      * based on the value for the first <code>Accept-Language</code> header
984      * that was encountered. If the request did not specify a preferred
985      * language, the server's default Locale is returned.
986      */

987     public Locale JavaDoc getLocale() {
988
989         if (!localesParsed)
990             parseLocales();
991
992         if (locales.size() > 0) {
993             return ((Locale JavaDoc) locales.get(0));
994         } else {
995             return (defaultLocale);
996         }
997
998     }
999
1000
1001    /**
1002     * Return the set of preferred Locales that the client will accept
1003     * content in, based on the values for any <code>Accept-Language</code>
1004     * headers that were encountered. If the request did not specify a
1005     * preferred language, the server's default Locale is returned.
1006     */

1007    public Enumeration JavaDoc getLocales() {
1008
1009        if (!localesParsed)
1010            parseLocales();
1011
1012        if (locales.size() > 0)
1013            return (new Enumerator(locales));
1014        ArrayList JavaDoc results = new ArrayList JavaDoc();
1015        results.add(defaultLocale);
1016        return (new Enumerator(results));
1017
1018    }
1019
1020
1021    /**<