-
Notifications
You must be signed in to change notification settings - Fork 5
/
Request.java
4346 lines (3899 loc) · 138 KB
/
Request.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.connector;
import com.sun.appserv.ProxyHandler;
import com.sun.enterprise.security.integration.RealmInitializer;
import com.sun.grizzly.tcp.ActionCode;
import com.sun.grizzly.tcp.CompletionHandler;
import com.sun.grizzly.util.buf.B2CConverter;
import com.sun.grizzly.util.buf.ByteChunk;
import com.sun.grizzly.util.buf.CharChunk;
import com.sun.grizzly.util.buf.MessageBytes;
import com.sun.grizzly.util.http.Cookies;
import com.sun.grizzly.util.http.FastHttpDateFormat;
import com.sun.grizzly.util.http.Parameters;
import com.sun.grizzly.util.http.ServerCookie;
import com.sun.grizzly.util.http.mapper.MappingData;
import org.apache.catalina.*;
import org.apache.catalina.authenticator.AuthenticatorBase;
import org.apache.catalina.authenticator.SingleSignOn;
import org.apache.catalina.core.ApplicationHttpRequest;
import org.apache.catalina.core.ApplicationHttpResponse;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.core.StandardWrapper;
import org.apache.catalina.deploy.LoginConfig;
import org.apache.catalina.fileupload.Multipart;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.session.PersistentManagerBase;
import org.apache.catalina.session.StandardSession;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.ParameterMap;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.util.StringParser;
import org.glassfish.web.valve.GlassFishValve;
import javax.security.auth.Subject;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URLDecoder;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.nio.charset.UnsupportedCharsetException;
import java.security.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Wrapper object for the Coyote request.
*
* @author Remy Maucherat
* @author Craig R. McClanahan
* @author Rajiv Mordani
* @version $Revision: 1.67.2.9 $ $Date: 2008/04/17 18:37:34 $
*/
public class Request
implements HttpRequest, HttpServletRequest {
// ----------------------------------------------------------- Statics
/**
* Descriptive information about this Request implementation.
*/
protected static final String info =
"org.apache.catalina.connector.Request/1.0";
/**
* Whether or not to enforce scope checking of this object.
*/
private static boolean enforceScope = false;
/**
* The notes key for the password used to authenticate this user.
*/
private static final String SESS_PASSWORD_NOTE =
"org.apache.catalina.session.PASSWORD";
/**
* The notes key for the username used to authenticate this user.
*/
private static final String SESS_USERNAME_NOTE =
"org.apache.catalina.session.USERNAME";
/**
* The string manager for this package.
*/
protected static final StringManager sm =
StringManager.getManager(Constants.Package);
// START CR 6309511
private static final Logger log =
Logger.getLogger(Request.class.getName());
// END CR 6309511
// START OF SJSAS 6231069
/*
protected SimpleDateFormat formats[] = {
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
}*/
/**
* The set of SimpleDateFormat formats to use in getDateHeader().
*
* Notice that because SimpleDateFormat is not thread-safe, we can't
* declare formats[] as a static variable.
*/
private static ThreadLocal staticDateFormats = new ThreadLocal() {
protected Object initialValue() {
SimpleDateFormat[] f = new SimpleDateFormat[3];
f[0] = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",
Locale.US);
f[1] = new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz",
Locale.US);
f[2] = new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US);
return f;
}
};
protected SimpleDateFormat formats[];
// END OF SJSAS 6231069
/**
* ThreadLocal object to keep track of the reentrancy status of each thread.
* It contains a byte[] object whose single element is either 0 (initial
* value or no reentrancy), or 1 (current thread is reentrant). When a
* thread exits the implies method, byte[0] is alwasy reset to 0.
*/
private static ThreadLocal reentrancyStatus;
static {
reentrancyStatus = new ThreadLocal() {
protected synchronized Object initialValue() {
return new byte[]{0};
}
};
}
// ----------------------------------------------------- Instance Variables
// Is the remote browser closed the connection.
protected boolean clientClosedConnection = false;
/**
* The set of cookies associated with this Request.
*/
protected ArrayList<Cookie> cookies = new ArrayList<Cookie>();
/**
* The default Locale if none are specified.
*/
protected static final Locale defaultLocale = Locale.getDefault();
/**
* The attributes associated with this Request, keyed by attribute name.
*/
protected HashMap<String, Object> attributes = new HashMap<String, Object>();
/**
* The preferred Locales associated with this Request.
*/
protected ArrayList<Locale> locales = new ArrayList<Locale>();
/**
* Internal notes associated with this request by Catalina components
* and event listeners.
*/
private HashMap<String, Object> notes = new HashMap<String, Object>();
/**
* Authentication type.
*/
protected String authType = null;
/**
* The current dispatcher type.
*/
protected Object dispatcherTypeAttr = null;
/**
* The associated input buffer.
*/
protected InputBuffer inputBuffer = new InputBuffer();
/**
* ServletInputStream.
*/
protected CoyoteInputStream inputStream =
new CoyoteInputStream(inputBuffer);
/**
* Reader.
*/
protected CoyoteReader reader = new CoyoteReader(inputBuffer);
/**
* Using stream flag.
*/
protected boolean usingInputStream = false;
/**
* Using writer flag.
*/
protected boolean usingReader = false;
/**
* User principal.
*/
protected Principal userPrincipal = null;
/**
* Session parsed flag.
*/
protected boolean sessionParsed = false;
/**
* Request parameters parsed flag.
*/
protected boolean requestParametersParsed = false;
/**
* Cookies parsed flag.
*/
protected boolean cookiesParsed = false;
/**
* Secure flag.
*/
protected boolean secure = false;
/**
* The Subject associated with the current AccessControllerContext
*/
protected Subject subject = null;
/**
* Post data buffer.
*/
protected static final int CACHED_POST_LEN = 8192;
protected byte[] postData = null;
/**
* Hash map used in the getParametersMap method.
*/
protected ParameterMap<String, String[]> parameterMap = new ParameterMap<String, String[]>();
/**
* The currently active session for this request.
*/
protected Session session = null;
/**
* The current request dispatcher path.
*/
protected Object requestDispatcherPath = null;
/**
* Was the requested session ID received in a cookie?
*/
protected boolean requestedSessionCookie = false;
/**
* The requested session ID (if any) for this request.
*/
protected String requestedSessionId = null;
/**
* The requested session version (if any) for this request.
*/
protected String requestedSessionVersion = null;
private boolean isRequestedSessionIdFromSecureCookie;
// The requested session cookie path, see IT 7426
protected String requestedSessionCookiePath;
// Temporary holder for URI params from which session id is parsed
protected CharChunk uriParamsCC = new CharChunk();
/**
* Was the requested session ID received in a URL?
*/
protected boolean requestedSessionURL = false;
/**
* The socket through which this Request was received.
*/
protected Socket socket = null;
/**
* Parse locales.
*/
protected boolean localesParsed = false;
/**
* The string parser we will use for parsing request lines.
*/
private StringParser parser = new StringParser();
/**
* Local port
*/
protected int localPort = -1;
/**
* Remote address.
*/
protected String remoteAddr = null;
/**
* Remote host.
*/
protected String remoteHost = null;
/**
* Remote port
*/
protected int remotePort = -1;
/**
* Local address
*/
protected String localName = null;
/**
* Local address
*/
protected String localAddr = null;
/** After the request is mapped to a ServletContext, we can also
* map it to a logger.
*/
/* CR 6309511
protected Log log=null;
*/
// START CR 6415120
/**
* Whether or not access to resources in WEB-INF or META-INF needs to be
* checked.
*/
protected boolean checkRestrictedResources = true;
// END CR 6415120
/**
* has findSession been called and returned null already
*/
private boolean unsuccessfulSessionFind = false;
/*
* Are we supposed to honor the unsuccessfulSessionFind flag?
* WS overrides this to false.
*/
protected boolean checkUnsuccessfulSessionFind = true;
// START S1AS 4703023
/**
* The current application dispatch depth.
*/
private int dispatchDepth = 0;
/**
* The maximum allowed application dispatch depth.
*/
private static int maxDispatchDepth = Constants.DEFAULT_MAX_DISPATCH_DEPTH;
// END S1AS 4703023
// START SJSAS 6346226
private String jrouteId;
// END SJSAS 6346226
// START GlassFish 896
private SessionTracker sessionTracker = new SessionTracker();
// END GlassFish 896
// START GlassFish 1024
private boolean isDefaultContext = false;
// END GlassFish 1024
private String requestURI = null;
/**
* Coyote request.
*/
protected com.sun.grizzly.tcp.Request coyoteRequest;
/**
* The facade associated with this request.
*/
protected RequestFacade facade = null;
/**
* Request facade that masks the fact that a request received
* at the root context was mapped to a default-web-module (if such a
* mapping exists).
* For example, its getContextPath() will return "/" rather than the
* context root of the default-web-module.
*/
protected RequestFacade defaultContextMaskingFacade = null;
/**
* The response with which this request is associated.
*/
protected org.apache.catalina.Response response = null;
/**
* Associated Catalina connector.
*/
protected org.apache.catalina.Connector connector;
/**
* Mapping data.
*/
protected MappingData mappingData = new MappingData();
/**
* Associated wrapper.
*/
protected Wrapper wrapper = null;
/**
* Filter chain associated with the request.
*/
protected FilterChain filterChain = null;
/**
* Async operation
*/
// Async mode is supported by default for a request, unless the request
// has passed a filter or servlet that does not support async
// operation, in which case async operation will be disabled
private boolean isAsyncSupported = true;
private AtomicBoolean asyncStarted = new AtomicBoolean();
private AsyncContextImpl asyncContext;
// Has AsyncContext.complete been called?
private boolean isAsyncComplete;
/**
* Multi-Part support
*/
private Multipart multipart;
/**
* Associated context.
*/
protected Context context = null;
protected ServletContext servletContext = null;
// Associated StandardHost valve for error dispatches
protected GlassFishValve hostValve;
/*
* The components of the request path
*/
private String contextPath;
private String servletPath;
private String pathInfo;
// Allow Grizzly to auto detect a remote close connection.
public final static boolean discardDisconnectEvent =
Boolean.getBoolean("com.sun.grizzly.discardDisconnect");
// ----------------------------------------------------------- Constructor
public Request() {
// START OF SJSAS 6231069
formats = (SimpleDateFormat[]) staticDateFormats.get();
formats[0].setTimeZone(TimeZone.getTimeZone("GMT"));
formats[1].setTimeZone(TimeZone.getTimeZone("GMT"));
formats[2].setTimeZone(TimeZone.getTimeZone("GMT"));
// END OF SJSAS 6231069
}
// --------------------------------------------------------- Public Methods
/**
* Set the Coyote request.
*
* @param coyoteRequest The Coyote request
*/
public void setCoyoteRequest(com.sun.grizzly.tcp.Request coyoteRequest) {
this.coyoteRequest = coyoteRequest;
inputBuffer.setRequest(coyoteRequest);
}
/**
* Get the Coyote request.
*/
public com.sun.grizzly.tcp.Request getCoyoteRequest() {
return (this.coyoteRequest);
}
/**
* Set whether or not to enforce scope checking of this object.
*/
public static void setEnforceScope(boolean enforce) {
enforceScope = enforce;
}
/**
* Release all object references, and initialize instance variables, in
* preparation for reuse of this object.
*/
@Override
public void recycle() {
if (isAsyncStarted()) {
return;
}
context = null;
servletContext = null;
contextPath = null;
servletPath = null;
pathInfo = null;
wrapper = null;
dispatcherTypeAttr = null;
requestDispatcherPath = null;
authType = null;
requestURI = null;
inputBuffer.recycle();
usingInputStream = false;
usingReader = false;
userPrincipal = null;
subject = null;
sessionParsed = false;
requestParametersParsed = false;
cookiesParsed = false;
locales.clear();
localesParsed = false;
secure = false;
remoteAddr = null;
remoteHost = null;
remotePort = -1;
localPort = -1;
localAddr = null;
localName = null;
multipart = null;
jrouteId = null;
attributes.clear();
notes.clear();
cookies.clear();
unsuccessfulSessionFind = false;
if (session != null) {
session.endAccess();
}
session = null;
requestedSessionCookie = false;
requestedSessionId = null;
requestedSessionCookiePath = null;
requestedSessionURL = false;
uriParamsCC.recycle();
// START GlassFish 896
sessionTracker.reset();
// END GlassFish 896
/* CR 6309511
log = null;
*/
dispatchDepth = 0; // S1AS 4703023
parameterMap.setLocked(false);
parameterMap.clear();
mappingData.recycle();
if (enforceScope) {
if (facade != null) {
facade.clear();
facade = null;
}
if (defaultContextMaskingFacade != null) {
defaultContextMaskingFacade.clear();
defaultContextMaskingFacade = null;
}
if (inputStream != null) {
inputStream.clear();
inputStream = null;
}
if (reader != null) {
reader.clear();
reader = null;
}
}
/*
* Clear and reinitialize all async related instance vars
*/
if (asyncContext != null) {
asyncContext.clear();
asyncContext = null;
}
isAsyncSupported = true;
asyncStarted.set(false);
isAsyncComplete = false;
clientClosedConnection = false;
}
/**
* Set the unsuccessfulSessionFind flag.
*
* @param unsuccessfulSessionFind
*/
public void setUnsuccessfulSessionFind(boolean unsuccessfulSessionFind) {
this.unsuccessfulSessionFind = unsuccessfulSessionFind;
}
/**
* Get the unsuccessfulSessionFind flag.
*/
public boolean getUnsuccessfulSessionFind() {
return this.unsuccessfulSessionFind;
}
// -------------------------------------------------------- Request Methods
/**
* Return the authorization credentials sent with this request.
*/
public String getAuthorization() {
return (coyoteRequest.getHeader(Constants.AUTHORIZATION_HEADER));
}
/**
* Return the Connector through which this Request was received.
*/
public org.apache.catalina.Connector getConnector() {
return connector;
}
/**
* Set the Connector through which this Request was received.
*
* @param connector The new connector
*/
public void setConnector(org.apache.catalina.Connector connector) {
this.connector = connector;
}
/**
* Return the Context within which this Request is being processed.
*/
public Context getContext() {
return context;
}
/**
* Set the Context within which this Request is being processed. This
* must be called as soon as the appropriate Context is identified, because
* it identifies the value to be returned by <code>getContextPath()</code>,
* and thus enables parsing of the request URI.
*
* @param context The newly associated Context
*/
public void setContext(Context context) {
this.context = context;
if (context != null) {
this.servletContext = context.getServletContext();
Pipeline p = context.getParent().getPipeline();
if (p != null) {
hostValve = p.getBasic();
}
}
// START GlassFish 896
initSessionTracker();
// END GlassFish 896
}
// START GlassFish 1024
/**
* @param isDefaultContext true if this request was mapped to a context
* with an empty context root that is backed by the vitual server's
* default-web-module
*/
public void setDefaultContext(boolean isDefaultContext) {
this.isDefaultContext = isDefaultContext;
}
// END GlassFish 1024
/**
* Get filter chain associated with the request.
*/
public FilterChain getFilterChain() {
return filterChain;
}
/**
* Set filter chain associated with the request.
*
* @param filterChain new filter chain
*/
public void setFilterChain(FilterChain filterChain) {
this.filterChain = filterChain;
}
/**
* Return the Host within which this Request is being processed.
*/
public Host getHost() {
return (Host) mappingData.host;
}
/**
* Set the Host within which this Request is being processed. This
* must be called as soon as the appropriate Host is identified, and
* before the Request is passed to a context.
*
* @param host The newly associated Host
*/
public void setHost(Host host) {
mappingData.host = host;
}
/**
* Return descriptive information about this Request implementation and
* the corresponding version number, in the format
* <code><description>/<version></code>.
*/
public String getInfo() {
return info;
}
/**
* Return mapping data.
*/
public MappingData getMappingData() {
return mappingData;
}
/**
* Set the mapping data for this Request.
*/
public void setMappingData(MappingData mappingData) {
this.mappingData = mappingData;
}
/**
* Update this instance with the content of the {@link MappingData}
* {@link MappingData}
*/
public void updatePaths(MappingData md) {
/*
* Save the path components of this request, in order for them to
* survive when the mapping data get recycled as the request
* returns to the container after it has been put into async mode.
* This is required to satisfy the requirements of subsequent async
* dispatches (or error dispatches, if the async operation times out,
* and no async listeners have been registered that could be notified
* at their onTimeout method)
*/
pathInfo = md.pathInfo.toString();
servletPath = md.wrapperPath.toString();
contextPath = md.contextPath.toString();
}
/**
* Gets the <code>ServletRequest</code> for which this object
* is the facade. This method must be implemented by a subclass.
*/
public HttpServletRequest getRequest() {
return getRequest(false);
}
/**
* Gets the <code>ServletRequest</code> for which this object
* is the facade. This method must be implemented by a subclass.
*
* @param maskDefaultContextMapping true if the fact that a request
* received at the root context was mapped to a default-web-module will
* be masked, false otherwise
*/
public HttpServletRequest getRequest(boolean maskDefaultContextMapping) {
if (!maskDefaultContextMapping || !isDefaultContext) {
if (facade == null) {
facade = new RequestFacade(this);
}
return facade;
} else {
if (defaultContextMaskingFacade == null) {
defaultContextMaskingFacade = new RequestFacade(this, true);
}
return defaultContextMaskingFacade;
}
}
/**
* Return the Response with which this Request is associated.
*/
public org.apache.catalina.Response getResponse() {
return (this.response);
}
/**
* Set the Response with which this Request is associated.
*
* @param response The new associated response
*/
public void setResponse(org.apache.catalina.Response response) {
this.response = response;
sessionTracker.setResponse((Response) response);
}
/**
* Return the Socket (if any) through which this Request was received.
* This should <strong>only</strong> be used to access underlying state
* information about this Socket, such as the SSLSession associated with
* an SSLSocket.
*/
public Socket getSocket() {
return (socket);
}
/**
* Set the Socket (if any) through which this Request was received.
*
* @param socket The socket through which this request was received
*/
public void setSocket(Socket socket) {
this.socket = socket;
remoteHost = null;
remoteAddr = null;
remotePort = -1;
localPort = -1;
localAddr = null;
localName = null;
}
/**
* Return the input stream associated with this Request.
*/
public InputStream getStream() {
if (inputStream == null) {
inputStream = new CoyoteInputStream(inputBuffer);
}
return inputStream;
}
/**
* Set the input stream associated with this Request.
*
* @param stream The new input stream
*/
public void setStream(InputStream stream) {
// Ignore
}
/**
* URI byte to char converter (not recycled).
*/
protected B2CConverter URIConverter = null;
/**
* Return the URI converter.
*/
protected B2CConverter getURIConverter() {
return URIConverter;
}
/**
* Set the URI converter.
*
* @param URIConverter the new URI converter
*/
protected void setURIConverter(B2CConverter URIConverter) {
this.URIConverter = URIConverter;
}
/**
* Return the Wrapper within which this Request is being processed.
*/
public Wrapper getWrapper() {
return wrapper;
}
/**
* Set the Wrapper within which this Request is being processed. This
* must be called as soon as the appropriate Wrapper is identified, and
* before the Request is ultimately passed to an application servlet.
* @param wrapper The newly associated Wrapper
*/
public void setWrapper(Wrapper wrapper) {
this.wrapper = wrapper;
}
// ------------------------------------------------- Request Public Methods
/**
* Create and return a ServletInputStream to read the content
* associated with this Request.
*
* @exception IOException if an input/output error occurs
*/
public ServletInputStream createInputStream()
throws IOException {
if (inputStream == null) {
inputStream = new CoyoteInputStream(inputBuffer);
}
return inputStream;
}
/**
* Perform whatever actions are required to flush and close the input
* stream or reader, in a single operation.
*
* @exception IOException if an input/output error occurs
*/
public void finishRequest() throws IOException {
// The reader and input stream don't need to be closed
}
/**
* Return the object bound with the specified name to the internal notes
* for this request, or <code>null</code> if no such binding exists.
*
* @param name Name of the note to be returned
*/
public Object getNote(String name) {
return (notes.get(name));
}
/**
* Return an Iterator containing the String names of all notes bindings
* that exist for this request.
*/
public Iterator<String> getNoteNames() {
return (notes.keySet().iterator());
}
/**
* Remove any object bound to the specified name in the internal notes
* for this request.
*
* @param name Name of the note to be removed
*/
public void removeNote(String name) {
notes.remove(name);
}
/**
* Bind an object to a specified name in the internal notes associated
* with this request, replacing any existing binding for this name.
*
* @param name Name to which the object should be bound
* @param value Object to be bound to the specified name
*/
public void setNote(String name, Object value) {
notes.put(name, value);
}
/**
* Set the content length associated with this Request.
*
* @param length The new content length
*/
public void setContentLength(int length) {
// Not used
}
/**
* Set the content type (and optionally the character encoding)
* associated with this Request. For example,
* <code>text/html; charset=ISO-8859-4</code>.
*
* @param type The new content type
*/
public void setContentType(String type) {
// Not used
}
/**
* Set the protocol name and version associated with this Request.
*
* @param protocol Protocol name and version
*/
public void setProtocol(String protocol) {
// Not used
}
/**
* Set the IP address of the remote client associated with this Request.
*
* @param remoteAddr The remote IP address
*/
public void setRemoteAddr(String remoteAddr) {
// Not used
}
/**