| 1 | | /* | | 1 | | /* | | 1 | | /* |
| 2 | | * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v 1.11.2.1 2002/02/15 23:0 5:36 craigmcc Exp $ | | 2 | | * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v 1.13 2002/03/18 07:15:40 remm Exp $ | | 2 | | * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v 1.13 2002/03/18 07:15:40 remm Exp $ |
| 3 | | * $Revision: 1.11.2.1 $ | | 3 | | * $Revision: 1.13 $ | | 3 | | * $Revision: 1.13 $ |
| 4 | | * $Date: 2002/02/15 23:0 5:36 $ | | 4 | | * $Date: 2002/03/18 07:15:40 $ | | 4 | | * $Date: 2002/03/18 07:15:40 $ |
| 5 | | * | | 5 | | * | | 5 | | * |
| 6 | | * ==================================================================== | | 6 | | * ==================================================================== | | 6 | | * ==================================================================== |
| 7 | | * | | 7 | | * | | 7 | | * |
| 8 | | * The Apache Software License, Version 1.1 | | 8 | | * The Apache Software License, Version 1.1 | | 8 | | * The Apache Software License, Version 1.1 |
| 9 | | * | | 9 | | * | | 9 | | * |
| 10 | | * Copyright (c) 1999 The Apache Software Foundation. All rights | | 10 | | * Copyright (c) 1999 The Apache Software Foundation. All rights | | 10 | | * Copyright (c) 1999 The Apache Software Foundation. All rights |
| 11 | | * reserved. | | 11 | | * reserved. | | 11 | | * reserved. |
| 12 | | * | | 12 | | * | | 12 | | * |
| 13 | | * Redistribution and use in source and binary forms, with or without | | 13 | | * Redistribution and use in source and binary forms, with or without | | 13 | | * Redistribution and use in source and binary forms, with or without |
| 14 | | * modification, are permitted provided that the following conditions | | 14 | | * modification, are permitted provided that the following conditions | | 14 | | * modification, are permitted provided that the following conditions |
| 15 | | * are met: | | 15 | | * are met: | | 15 | | * are met: |
| 16 | | * | | 16 | | * | | 16 | | * |
| 17 | | * 1. Redistributions of source code must retain the above copyright | | 17 | | * 1. Redistributions of source code must retain the above copyright | | 17 | | * 1. Redistributions of source code must retain the above copyright |
| 18 | | * notice, this list of conditions and the following disclaimer. | | 18 | | * notice, this list of conditions and the following disclaimer. | | 18 | | * notice, this list of conditions and the following disclaimer. |
| 19 | | * | | 19 | | * | | 19 | | * |
| 20 | | * 2. Redistributions in binary form must reproduce the above copyright | | 20 | | * 2. Redistributions in binary form must reproduce the above copyright | | 20 | | * 2. Redistributions in binary form must reproduce the above copyright |
| 21 | | * notice, this list of conditions and the following disclaimer in | | 21 | | * notice, this list of conditions and the following disclaimer in | | 21 | | * notice, this list of conditions and the following disclaimer in |
| 22 | | * the documentation and/or other materials provided with the | | 22 | | * the documentation and/or other materials provided with the | | 22 | | * the documentation and/or other materials provided with the |
| 23 | | * distribution. | | 23 | | * distribution. | | 23 | | * distribution. |
| 24 | | * | | 24 | | * | | 24 | | * |
| 25 | | * 3. The end-user documentation included with the redistribution, if | | 25 | | * 3. The end-user documentation included with the redistribution, if | | 25 | | * 3. The end-user documentation included with the redistribution, if |
| 26 | | * any, must include the following acknowlegement: | | 26 | | * any, must include the following acknowlegement: | | 26 | | * any, must include the following acknowlegement: |
| 27 | | * "This product includes software developed by the | | 27 | | * "This product includes software developed by the | | 27 | | * "This product includes software developed by the |
| 28 | | * Apache Software Foundation (http://www.apache.org/)." | | 28 | | * Apache Software Foundation (http://www.apache.org/)." | | 28 | | * Apache Software Foundation (http://www.apache.org/)." |
| 29 | | * Alternately, this acknowlegement may appear in the software itself, | | 29 | | * Alternately, this acknowlegement may appear in the software itself, | | 29 | | * Alternately, this acknowlegement may appear in the software itself, |
| 30 | | * if and wherever such third-party acknowlegements normally appear. | | 30 | | * if and wherever such third-party acknowlegements normally appear. | | 30 | | * if and wherever such third-party acknowlegements normally appear. |
| 31 | | * | | 31 | | * | | 31 | | * |
| 32 | | * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | | 32 | | * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | | 32 | | * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software |
| 33 | | * Foundation" must not be used to endorse or promote products derived | | 33 | | * Foundation" must not be used to endorse or promote products derived | | 33 | | * Foundation" must not be used to endorse or promote products derived |
| 34 | | * from this software without prior written permission. For written | | 34 | | * from this software without prior written permission. For written | | 34 | | * from this software without prior written permission. For written |
| 35 | | * permission, please contact apache@apache.org. | | 35 | | * permission, please contact apache@apache.org. | | 35 | | * permission, please contact apache@apache.org. |
| 36 | | * | | 36 | | * | | 36 | | * |
| 37 | | * 5. Products derived from this software may not be called "Apache" | | 37 | | * 5. Products derived from this software may not be called "Apache" | | 37 | | * 5. Products derived from this software may not be called "Apache" |
| 38 | | * nor may "Apache" appear in their names without prior written | | 38 | | * nor may "Apache" appear in their names without prior written | | 38 | | * nor may "Apache" appear in their names without prior written |
| 39 | | * permission of the Apache Group. | | 39 | | * permission of the Apache Group. | | 39 | | * permission of the Apache Group. |
| 40 | | * | | 40 | | * | | 40 | | * |
| 41 | | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | | 41 | | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | | 41 | | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| 42 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 42 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 42 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 43 | | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 43 | | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 43 | | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 44 | | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | | 44 | | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | | 44 | | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR |
| 45 | | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 45 | | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 45 | | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 46 | | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | | 46 | | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | | 46 | | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 47 | | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | | 47 | | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | | 47 | | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 48 | | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | | 48 | | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | | 48 | | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 49 | | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 49 | | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 49 | | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 50 | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | | 50 | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | | 50 | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 51 | | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 51 | | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 51 | | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 52 | | * SUCH DAMAGE. | | 52 | | * SUCH DAMAGE. | | 52 | | * SUCH DAMAGE. |
| 53 | | * ==================================================================== | | 53 | | * ==================================================================== | | 53 | | * ==================================================================== |
| 54 | | * | | 54 | | * | | 54 | | * |
| 55 | | * This software consists of voluntary contributions made by many | | 55 | | * This software consists of voluntary contributions made by many | | 55 | | * This software consists of voluntary contributions made by many |
| 56 | | * individuals on behalf of the Apache Software Foundation. For more | | 56 | | * individuals on behalf of the Apache Software Foundation. For more | | 56 | | * individuals on behalf of the Apache Software Foundation. For more |
| 57 | | * information on the Apache Software Foundation, please see | | 57 | | * information on the Apache Software Foundation, please see | | 57 | | * information on the Apache Software Foundation, please see |
| 58 | | * <http://www.apache.org/>. | | 58 | | * <http://www.apache.org/>. | | 58 | | * <http://www.apache.org/>. |
| 59 | | * | | 59 | | * | | 59 | | * |
| 60 | | * [Additional notices, if required by prior licensing conditions] | | 60 | | * [Additional notices, if required by prior licensing conditions] | | 60 | | * [Additional notices, if required by prior licensing conditions] |
| 61 | | * | | 61 | | * | | 61 | | * |
| 62 | | */ | | 62 | | */ | | 62 | | */ |
| 63 | | | | 63 | | | | 63 | | |
| 64 | | | | 64 | | | | 64 | | |
| 65 | | package org.apache.catalina.connector.http; | | 65 | | package org.apache.catalina.connector.http; | | 65 | | package org.apache.catalina.connector.http; |
| 66 | | | | 66 | | | | 66 | | |
| 67 | | | | 67 | | | | 67 | | |
| 68 | | import java.io.IOException; | | 68 | | import java.io.IOException; | | 68 | | import java.io.IOException; |
| 69 | | import java.net.InetAddress; | | 69 | | import java.net.InetAddress; | | 69 | | import java.net.InetAddress; |
| 70 | | import java.security.AccessController; | | 70 | | import java.security.AccessController; | | 70 | | import java.security.AccessController; |
| 71 | | import java.security.PrivilegedAction; | | 71 | | import java.security.PrivilegedAction; | | 71 | | import java.security.PrivilegedAction; |
| 72 | | import java.util.ArrayList; | | 72 | | import java.util.ArrayList; | | 72 | | import java.util.ArrayList; |
| 73 | | import java.util.Enumeration; | | 73 | | import java.util.Enumeration; | | 73 | | import java.util.Enumeration; |
| 74 | | import javax.servlet.ServletInputStream; | | 74 | | import javax.servlet.ServletInputStream; | | 74 | | import javax.servlet.ServletInputStream; |
| 75 | | import org.apache.catalina.connector.HttpRequestBase; | | 75 | | import org.apache.catalina.connector.HttpRequestBase; | | 75 | | import org.apache.catalina.connector.HttpRequestBase; |
| 76 | | import org.apache.catalina.util.Enumerator; | | 76 | | import org.apache.catalina.util.Enumerator; | | 76 | | import org.apache.catalina.util.Enumerator; |
| 77 | | | | 77 | | | | 77 | | |
| 78 | | | | 78 | | | | 78 | | |
| 79 | | /** | | 79 | | /** | | 79 | | /** |
| 80 | | * Implementation of <b>HttpRequest</b> specific to the HTTP connector. | | 80 | | * Implementation of <b>HttpRequest</b> specific to the HTTP connector. | | 80 | | * Implementation of <b>HttpRequest</b> specific to the HTTP connector. |
| 81 | | * | | 81 | | * | | 81 | | * |
| 82 | | * @author Craig R. McClanahan | | 82 | | * @author Craig R. McClanahan | | 82 | | * @author Craig R. McClanahan |
| 83 | | * @author Remy Maucherat | | 83 | | * @author Remy Maucherat | | 83 | | * @author Remy Maucherat |
| 84 | | * @version $Revision: 1.11.2.1 $ $Date: 2002/02/15 23:0 5:36 $ | | 84 | | * @version $Revision: 1.13 $ $Date: 2002/03/18 07:15:40 $ | | 84 | | * @version $Revision: 1.13 $ $Date: 2002/03/18 07:15:40 $ |
| | | | | 85 | | * @deprecated | | 85 | | * @deprecated |
| 85 | | */ | | 86 | | */ | | 86 | | */ |
| 86 | | | | 87 | | | | 87 | | |
| 87 | | final class HttpRequestImpl | | 88 | | final class HttpRequestImpl | | 88 | | final class HttpRequestImpl |
| 88 | | extends HttpRequestBase { | | 89 | | extends HttpRequestBase { | | 89 | | extends HttpRequestBase { |
| 89 | | | | 90 | | | | 90 | | |
| 90 | | | | 91 | | | | 91 | | |
| 91 | | // -------------------------------------------------------------- Constants | | 92 | | // -------------------------------------------------------------- Constants | | 92 | | // -------------------------------------------------------------- Constants |
| 92 | | | | 93 | | | | 93 | | |
| 93 | | | | 94 | | | | 94 | | |
| 94 | | /** | | 95 | | /** | | 95 | | /** |
| 95 | | * Initial pool size. | | 96 | | * Initial pool size. | | 96 | | * Initial pool size. |
| 96 | | */ | | 97 | | */ | | 97 | | */ |
| 97 | | protected static final int INITIAL_POOL_SIZE = 10; | | 98 | | protected static final int INITIAL_POOL_SIZE = 10; | | 98 | | protected static final int INITIAL_POOL_SIZE = 10; |
| 98 | | | | 99 | | | | 99 | | |
| 99 | | | | 100 | | | | 100 | | |
| 100 | | /** | | 101 | | /** | | 101 | | /** |
| 101 | | * Pool size increment. | | 102 | | * Pool size increment. | | 102 | | * Pool size increment. |
| 102 | | */ | | 103 | | */ | | 103 | | */ |
| 103 | | protected static final int POOL_SIZE_INCREMENT = 5; | | 104 | | protected static final int POOL_SIZE_INCREMENT = 5; | | 104 | | protected static final int POOL_SIZE_INCREMENT = 5; |
| 104 | | | | 105 | | | | 105 | | |
| 105 | | | | 106 | | | | 106 | | |
| 106 | | // ----------------------------------------------------- Instance Variables | | 107 | | // ----------------------------------------------------- Instance Variables | | 107 | | // ----------------------------------------------------- Instance Variables |
| 107 | | | | 108 | | | | 108 | | |
| 108 | | | | 109 | | | | 109 | | |
| 109 | | /** | | 110 | | /** | | 110 | | /** |
| 110 | | * The InetAddress of the remote client of ths request. | | 111 | | * The InetAddress of the remote client of ths request. | | 111 | | * The InetAddress of the remote client of ths request. |
| 111 | | */ | | 112 | | */ | | 112 | | */ |
| 112 | | protected InetAddress inet = null; | | 113 | | protected InetAddress inet = null; | | 113 | | protected InetAddress inet = null; |
| 113 | | | | 114 | | | | 114 | | |
| 114 | | | | 115 | | | | 115 | | |
| 115 | | /** | | 116 | | /** | | 116 | | /** |
| 116 | | * Descriptive information about this Request implementation. | | 117 | | * Descriptive information about this Request implementation. | | 117 | | * Descriptive information about this Request implementation. |
| 117 | | */ | | 118 | | */ | | 118 | | */ |
| 118 | | protected static final String info = | | 119 | | protected static final String info = | | 119 | | protected static final String info = |
| 119 | | "org.apache.catalina.connector.http.HttpRequestImpl/1.0"; | | 120 | | "org.apache.catalina.connector.http.HttpRequestImpl/1.0"; | | 120 | | "org.apache.catalina.connector.http.HttpRequestImpl/1.0"; |
| 120 | | | | 121 | | | | 121 | | |
| 121 | | | | 122 | | | | 122 | | |
| 122 | | /** | | 123 | | /** | | 123 | | /** |
| 123 | | * Headers pool. | | 124 | | * Headers pool. | | 124 | | * Headers pool. |
| 124 | | */ | | 125 | | */ | | 125 | | */ |
| 125 | | protected HttpHeader[] headerPool = new HttpHeader[INITIAL_POOL_SIZE]; | | 126 | | protected HttpHeader[] headerPool = new HttpHeader[INITIAL_POOL_SIZE]; | | 126 | | protected HttpHeader[] headerPool = new HttpHeader[INITIAL_POOL_SIZE]; |
| 126 | | | | 127 | | | | 127 | | |
| 127 | | | | 128 | | | | 128 | | |
| 128 | | /** | | 129 | | /** | | 129 | | /** |
| 129 | | * Position of the next available header in the pool. | | 130 | | * Position of the next available header in the pool. | | 130 | | * Position of the next available header in the pool. |
| 130 | | */ | | 131 | | */ | | 131 | | */ |
| 131 | | protected int nextHeader = 0; | | 132 | | protected int nextHeader = 0; | | 132 | | protected int nextHeader = 0; |
| 132 | | | | 133 | | | | 133 | | |
| 133 | | | | 134 | | | | 134 | | |
| 134 | | /** | | 135 | | /** | | 135 | | /** |
| 135 | | * Connection header. | | 136 | | * Connection header. | | 136 | | * Connection header. |
| 136 | | */ | | 137 | | */ | | 137 | | */ |
| 137 | | protected HttpHeader connectionHeader = null; | | 138 | | protected HttpHeader connectionHeader = null; | | 138 | | protected HttpHeader connectionHeader = null; |
| 138 | | | | 139 | | | | 139 | | |
| 139 | | | | 140 | | | | 140 | | |
| 140 | | /** | | 141 | | /** | | 141 | | /** |
| 141 | | * Transfer encoding header. | | 142 | | * Transfer encoding header. | | 142 | | * Transfer encoding header. |
| 142 | | */ | | 143 | | */ | | 143 | | */ |
| 143 | | protected HttpHeader transferEncodingHeader = null; | | 144 | | protected HttpHeader transferEncodingHeader = null; | | 144 | | protected HttpHeader transferEncodingHeader = null; |
| 144 | | | | 145 | | | | 145 | | |
| 145 | | | | 146 | | | | 146 | | |
| 146 | | // ------------------------------------------------------------- Properties | | 147 | | // ------------------------------------------------------------- Properties | | 147 | | // ------------------------------------------------------------- Properties |
| 147 | | | | 148 | | | | 148 | | |
| 148 | | | | 149 | | | | 149 | | |
| 149 | | /** | | 150 | | /** | | 150 | | /** |
| 150 | | * [Package Private] Return the InetAddress of the remote client of | | 151 | | * [Package Private] Return the InetAddress of the remote client of | | 151 | | * [Package Private] Return the InetAddress of the remote client of |
| 151 | | * this request. | | 152 | | * this request. | | 152 | | * this request. |
| 152 | | */ | | 153 | | */ | | 153 | | */ |
| 153 | | InetAddress getInet() { | | 154 | | InetAddress getInet() { | | 154 | | InetAddress getInet() { |
| 154 | | | | 155 | | | | 155 | | |
| 155 | | return (inet); | | 156 | | return (inet); | | 156 | | return (inet); |
| 156 | | | | 157 | | | | 157 | | |
| 157 | | } | | 158 | | } | | 158 | | } |
| 158 | | | | 159 | | | | 159 | | |
| 159 | | | | 160 | | | | 160 | | |
| 160 | | /** | | 161 | | /** | | 161 | | /** |
| 161 | | * [Package Private] Set the InetAddress of the remote client of | | 162 | | * [Package Private] Set the InetAddress of the remote client of | | 162 | | * [Package Private] Set the InetAddress of the remote client of |
| 162 | | * this request. | | 163 | | * this request. | | 163 | | * this request. |
| 163 | | * | | 164 | | * | | 164 | | * |
| 164 | | * @param inet The new InetAddress | | 165 | | * @param inet The new InetAddress | | 165 | | * @param inet The new InetAddress |
| 165 | | */ | | 166 | | */ | | 166 | | */ |
| 166 | | void setInet(InetAddress inet) { | | 167 | | void setInet(InetAddress inet) { | | 167 | | void setInet(InetAddress inet) { |
| 167 | | | | 168 | | | | 168 | | |
| 168 | | this.inet = inet; | | 169 | | this.inet = inet; | | 169 | | this.inet = inet; |
| 169 | | | | 170 | | | | 170 | | |
| 170 | | } | | 171 | | } | | 171 | | } |
| 171 | | | | 172 | | | | 172 | | |
| 172 | | | | 173 | | | | 173 | | |
| 173 | | /** | | 174 | | /** | | 174 | | /** |
| 174 | | * Return descriptive information about this Request implementation and | | 175 | | * Return descriptive information about this Request implementation and | | 175 | | * Return descriptive information about this Request implementation and |
| 175 | | * the corresponding version number, in the format | | 176 | | * the corresponding version number, in the format | | 176 | | * the corresponding version number, in the format |
| 176 | | * <code><description>/<version></code>. | | 177 | | * <code><description>/<version></code>. | | 177 | | * <code><description>/<version></code>. |
| 177 | | */ | | 178 | | */ | | 178 | | */ |
| 178 | | public String getInfo() { | | 179 | | public String getInfo() { | | 179 | | public String getInfo() { |
| 179 | | | | 180 | | | | 180 | | |
| 180 | | return (info); | | 181 | | return (info); | | 181 | | return (info); |
| 181 | | | | 182 | | | | 182 | | |
| 182 | | } | | 183 | | } | | 183 | | } |
| 183 | | | | 184 | | | | 184 | | |
| 184 | | | | 185 | | | | 185 | | |
| 185 | | // --------------------------------------------------------- Public Methods | | 186 | | // --------------------------------------------------------- Public Methods | | 186 | | // --------------------------------------------------------- Public Methods |
| 186 | | | | 187 | | | | 187 | | |
| 187 | | | | 188 | | | | 188 | | |
| 188 | | /** | | 189 | | /** | | 189 | | /** |
| 189 | | * Release all object references, and initialize instance variables, in | | 190 | | * Release all object references, and initialize instance variables, in | | 190 | | * Release all object references, and initialize instance variables, in |
| 190 | | * preparation for reuse of this object. | | 191 | | * preparation for reuse of this object. | | 191 | | * preparation for reuse of this object. |
| 191 | | */ | | 192 | | */ | | 192 | | */ |
| 192 | | public void recycle() { | | 193 | | public void recycle() { | | 193 | | public void recycle() { |
| 193 | | | | 194 | | | | 194 | | |
| 194 | | super.recycle(); | | 195 | | super.recycle(); | | 195 | | super.recycle(); |
| 195 | | inet = null; | | 196 | | inet = null; | | 196 | | inet = null; |
| 196 | | nextHeader = 0; | | 197 | | nextHeader = 0; | | 197 | | nextHeader = 0; |
| 197 | | connectionHeader = null; | | 198 | | connectionHeader = null; | | 198 | | connectionHeader = null; |
| 198 | | | | 199 | | | | 199 | | |
| 199 | | } | | 200 | | } | | 200 | | } |
| 200 | | | | 201 | | | | 201 | | |
| 201 | | | | 202 | | | | 202 | | |
| 202 | | /** | | 203 | | /** | | 203 | | /** |
| 203 | | * Create and return a ServletInputStream to read the content | | 204 | | * Create and return a ServletInputStream to read the content | | 204 | | * Create and return a ServletInputStream to read the content |
| 204 | | * associated with this Request. The default implementation creates an | | 205 | | * associated with this Request. The default implementation creates an | | 205 | | * associated with this Request. The default implementation creates an |
| 205 | | * instance of RequestStream associated with this request, but this can | | 206 | | * instance of RequestStream associated with this request, but this can | | 206 | | * instance of RequestStream associated with this request, but this can |
| 206 | | * be overridden if necessary. | | 207 | | * be overridden if necessary. | | 207 | | * be overridden if necessary. |
| 207 | | * | | 208 | | * | | 208 | | * |
| 208 | | * @exception IOException if an input/output error occurs | | 209 | | * @exception IOException if an input/output error occurs | | 209 | | * @exception IOException if an input/output error occurs |
| 209 | | */ | | 210 | | */ | | 210 | | */ |
| 210 | | public ServletInputStream createInputStream() throws IOException { | | 211 | | public ServletInputStream createInputStream() throws IOException { | | 211 | | public ServletInputStream createInputStream() throws IOException { |
| 211 | | | | 212 | | | | 212 | | |
| 212 | | return (new HttpRequestStream(this, (HttpResponseImpl) response)); | | 213 | | return (new HttpRequestStream(this, (HttpResponseImpl) response)); | | 213 | | return (new HttpRequestStream(this, (HttpResponseImpl) response)); |
| 213 | | | | 214 | | | | 214 | | |
| 214 | | } | | 215 | | } | | 215 | | } |
| 215 | | | | 216 | | | | 216 | | |
| 216 | | | | 217 | | | | 217 | | |
| 217 | | /** | | 218 | | /** | | 218 | | /** |
| 218 | | * Allocate new header. | | 219 | | * Allocate new header. | | 219 | | * Allocate new header. |
| 219 | | * | | 220 | | * | | 220 | | * |
| 220 | | * @return an HttpHeader buffer allocated from the pool | | 221 | | * @return an HttpHeader buffer allocated from the pool | | 221 | | * @return an HttpHeader buffer allocated from the pool |
| 221 | | */ | | 222 | | */ | | 222 | | */ |
| 222 | | HttpHeader allocateHeader() { | | 223 | | HttpHeader allocateHeader() { | | 223 | | HttpHeader allocateHeader() { |
| 223 | | if (nextHeader == headerPool.length) { | | 224 | | if (nextHeader == headerPool.length) { | | 224 | | if (nextHeader == headerPool.length) { |
| 224 | | // Grow the pool | | 225 | | // Grow the pool | | 225 | | // Grow the pool |
| 225 | | HttpHeader[] newHeaderPool = | | 226 | | HttpHeader[] newHeaderPool = | | 226 | | HttpHeader[] newHeaderPool = |
| 226 | | new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT]; | | 227 | | new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT]; | | 227 | | new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT]; |
| 227 | | for (int i = 0; i < nextHeader; i++) { | | 228 | | for (int i = 0; i < nextHeader; i++) { | | 228 | | for (int i = 0; i < nextHeader; i++) { |
| 228 | | newHeaderPool[i] = headerPool[i]; | | 229 | | newHeaderPool[i] = headerPool[i]; | | 229 | | newHeaderPool[i] = headerPool[i]; |
| 229 | | } | | 230 | | } | | 230 | | } |
| 230 | | headerPool = newHeaderPool; | | 231 | | headerPool = newHeaderPool; | | 231 | | headerPool = newHeaderPool; |
| 231 | | } | | 232 | | } | | 232 | | } |
| 232 | | if (headerPool[nextHeader] == null) | | 233 | | if (headerPool[nextHeader] == null) | | 233 | | if (headerPool[nextHeader] == null) |
| 233 | | headerPool[nextHeader] = new HttpHeader(); | | 234 | | headerPool[nextHeader] = new HttpHeader(); | | 234 | | headerPool[nextHeader] = new HttpHeader(); |
| 234 | | return headerPool[nextHeader]; | | 235 | | return headerPool[nextHeader]; | | 235 | | return headerPool[nextHeader]; |
| 235 | | } | | 236 | | } | | 236 | | } |
| 236 | | | | 237 | | | | 237 | | |
| 237 | | | | 238 | | | | 238 | | |
| 238 | | /** | | 239 | | /** | | 239 | | /** |
| 239 | | * Go to the next header. | | 240 | | * Go to the next header. | | 240 | | * Go to the next header. |
| 240 | | */ | | 241 | | */ | | 241 | | */ |
| 241 | | void nextHeader() { | | 242 | | void nextHeader() { | | 242 | | void nextHeader() { |
| 242 | | nextHeader++; | | 243 | | nextHeader++; | | 243 | | nextHeader++; |
| 243 | | } | | 244 | | } | | 244 | | } |
| 244 | | | | 245 | | | | 245 | | |
| 245 | | | | 246 | | | | 246 | | |
| 246 | | /** | | 247 | | /** | | 247 | | /** |
| 247 | | * Add a Header to the set of Headers associated with this Request. | | 248 | | * Add a Header to the set of Headers associated with this Request. | | 248 | | * Add a Header to the set of Headers associated with this Request. |
| 248 | | * | | 249 | | * | | 249 | | * |
| 249 | | * @param name The new header name | | 250 | | * @param name The new header name | | 250 | | * @param name The new header name |
| 250 | | * @param value The new header value | | 251 | | * @param value The new header value | | 251 | | * @param value The new header value |
| 251 | | * @deprecated Don't use | | 252 | | * @deprecated Don't use | | 252 | | * @deprecated Don't use |
| 252 | | */ | | 253 | | */ | | 253 | | */ |
| 253 | | public void addHeader(String name, String value) { | | 254 | | public void addHeader(String name, String value) { | | 254 | | public void addHeader(String name, String value) { |
| 254 | | | | 255 | | | | 255 | | |
| 255 | | if (nextHeader == headerPool.length) { | | 256 | | if (nextHeader == headerPool.length) { | | 256 | | if (nextHeader == headerPool.length) { |
| 256 | | // Grow the pool | | 257 | | // Grow the pool | | 257 | | // Grow the pool |
| 257 | | HttpHeader[] newHeaderPool = | | 258 | | HttpHeader[] newHeaderPool = | | 258 | | HttpHeader[] newHeaderPool = |
| 258 | | new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT]; | | 259 | | new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT]; | | 259 | | new HttpHeader[headerPool.length + POOL_SIZE_INCREMENT]; |
| 259 | | for (int i = 0; i < nextHeader; i++) { | | 260 | | for (int i = 0; i < nextHeader; i++) { | | 260 | | for (int i = 0; i < nextHeader; i++) { |
| 260 | | newHeaderPool[i] = headerPool[i]; | | 261 | | newHeaderPool[i] = headerPool[i]; | | 261 | | newHeaderPool[i] = headerPool[i]; |
| 261 | | } | | 262 | | } | | 262 | | } |
| 262 | | headerPool = newHeaderPool; | | 263 | | headerPool = newHeaderPool; | | 263 | | headerPool = newHeaderPool; |
| 263 | | } | | 264 | | } | | 264 | | } |
| 264 | | headerPool[nextHeader++] = new HttpHeader(name, value); | | 265 | | headerPool[nextHeader++] = new HttpHeader(name, value); | | 265 | | headerPool[nextHeader++] = new HttpHeader(name, value); |
| 265 | | | | 266 | | | | 266 | | |
| 266 | | } | | 267 | | } | | 267 | | } |
| 267 | | | | 268 | | | | 268 | | |
| 268 | | | | 269 | | | | 269 | | |
| 269 | | /** | | 270 | | /** | | 270 | | /** |
| 270 | | * Clear the collection of Headers associated with this Request. | | 271 | | * Clear the collection of Headers associated with this Request. | | 271 | | * Clear the collection of Headers associated with this Request. |
| 271 | | */ | | 272 | | */ | | 272 | | */ |
| 272 | | public void clearHeaders() { | | 273 | | public void clearHeaders() { | | 273 | | public void clearHeaders() { |
| 273 | | | | 274 | | | | 274 | | |
| 274 | | nextHeader = 0; | | 275 | | nextHeader = 0; | | 275 | | nextHeader = 0; |
| 275 | | | | 276 | | | | 276 | | |
| 276 | | } | | 277 | | } | | 277 | | } |
| 277 | | | | 278 | | | | 278 | | |
| 278 | | | | 279 | | | | 279 | | |
| 279 | | /** | | 280 | | /** | | 280 | | /** |
| 280 | | * Return the first value of the specified header, if any; otherwise, | | 281 | | * Return the first value of the specified header, if any; otherwise, | | 281 | | * Return the first value of the specified header, if any; otherwise, |
| 281 | | * return <code>null</code> | | 282 | | * return <code>null</code> | | 282 | | * return <code>null</code> |
| 282 | | * | | 283 | | * | | 283 | | * |
| 283 | | * @param header Header we want to retrieve | | 284 | | * @param header Header we want to retrieve | | 284 | | * @param header Header we want to retrieve |
| 284 | | */ | | 285 | | */ | | 285 | | */ |
| 285 | | public HttpHeader getHeader(HttpHeader header) { | | 286 | | public HttpHeader getHeader(HttpHeader header) { | | 286 | | public HttpHeader getHeader(HttpHeader header) { |
| 286 | | | | 287 | | | | 287 | | |
| 287 | | for (int i = 0; i < nextHeader; i++) { | | 288 | | for (int i = 0; i < nextHeader; i++) { | | 288 | | for (int i = 0; i < nextHeader; i++) { |
| 288 | | if (headerPool[i].equals(header)) | | 289 | | if (headerPool[i].equals(header)) | | 289 | | if (headerPool[i].equals(header)) |
| 289 | | return headerPool[i]; | | 290 | | return headerPool[i]; | | 290 | | return headerPool[i]; |
| 290 | | } | | 291 | | } | | 291 | | } |
| 291 | | return null; | | 292 | | return null; | | 292 | | return null; |
| 292 | | | | 293 | | | | 293 | | |
| 293 | | } | | 294 | | } | | 294 | | } |
| 294 | | | | 295 | | | | 295 | | |
| 295 | | | | 296 | | | | 296 | | |
| 296 | | /** | | 297 | | /** | | 297 | | /** |
| 297 | | * Return the first value of the specified header, if any; otherwise, | | 298 | | * Return the first value of the specified header, if any; otherwise, | | 298 | | * Return the first value of the specified header, if any; otherwise, |
| 298 | | * return <code>null</code> | | 299 | | * return <code>null</code> | | 299 | | * return <code>null</code> |
| 299 | | * | | 300 | | * | | 300 | | * |
| 300 | | * @param headerName Name of the requested header | | 301 | | * @param headerName Name of the requested header | | 301 | | * @param headerName Name of the requested header |
| 301 | | */ | | 302 | | */ | | 302 | | */ |
| 302 | | public HttpHeader getHeader(char[] headerName) { | | 303 | | public HttpHeader getHeader(char[] headerName) { | | 303 | | public HttpHeader getHeader(char[] headerName) { |
| 303 | | | | 304 | | | | 304 | | |
| 304 | | for (int i = 0; i < nextHeader; i++) { | | 305 | | for (int i = 0; i < nextHeader; i++) { | | 305 | | for (int i = 0; i < nextHeader; i++) { |
| 305 | | if (headerPool[i].equals(headerName)) | | 306 | | if (headerPool[i].equals(headerName)) | | 306 | | if (headerPool[i].equals(headerName)) |
| 306 | | return headerPool[i]; | | 307 | | return headerPool[i]; | | 307 | | return headerPool[i]; |
| 307 | | } | | 308 | | } | | 308 | | } |
| 308 | | return null; | | 309 | | return null; | | 309 | | return null; |
| 309 | | | | 310 | | | | 310 | | |
| 310 | | } | | 311 | | } | | 311 | | } |
| 311 | | | | 312 | | | | 312 | | |
| 312 | | | | 313 | | | | 313 | | |
| 313 | | /** | | 314 | | /** | | 314 | | /** |
| 314 | | * Perform whatever actions are required to flush and close the input | | 315 | | * Perform whatever actions are required to flush and close the input | | 315 | | * Perform whatever actions are required to flush and close the input |
| 315 | | * stream or reader, in a single operation. | | 316 | | * stream or reader, in a single operation. | | 316 | | * stream or reader, in a single operation. |
| 316 | | * | | 317 | | * | | 317 | | * |
| 317 | | * @exception IOException if an input/output error occurs | | 318 | | * @exception IOException if an input/output error occurs | | 318 | | * @exception IOException if an input/output error occurs |
| 318 | | */ | | 319 | | */ | | 319 | | */ |
| 319 | | public void finishRequest() throws IOException { | | 320 | | public void finishRequest() throws IOException { | | 320 | | public void finishRequest() throws IOException { |
| 320 | | | | 321 | | | | 321 | | |
| 321 | | // If neither a reader or an is have been opened, do it to consume | | 322 | | // If neither a reader or an is have been opened, do it to consume | | 322 | | // If neither a reader or an is have been opened, do it to consume |
| 322 | | // request bytes, if any | | 323 | | // request bytes, if any | | 323 | | // request bytes, if any |
| 323 | | if ((reader == null) && (stream == null) && (getContentLength() != 0) | | 324 | | if ((reader == null) && (stream == null) && (getContentLength() != 0) | | 324 | | if ((reader == null) && (stream == null) && (getContentLength() != 0) |
| 324 | | && (getProtocol() != null) && (getProtocol().equals("HTTP/1.1"))) | | 325 | | && (getProtocol() != null) && (getProtocol().equals("HTTP/1.1"))) | | 325 | | && (getProtocol() != null) && (getProtocol().equals("HTTP/1.1"))) |
| 325 | | getInputStream(); | | 326 | | getInputStream(); | | 326 | | getInputStream(); |
| 326 | | | | 327 | | | | 327 | | |
| 327 | | super.finishRequest(); | | 328 | | super.finishRequest(); | | 328 | | super.finishRequest(); |
| 328 | | | | 329 | | | | 329 | | |
| 329 | | } | | 330 | | } | | 330 | | } |
| 330 | | | | 331 | | | | 331 | | |
| 331 | | | | 332 | | | | 332 | | |
| 332 | | // ------------------------------------------------- ServletRequest Methods | | 333 | | // ------------------------------------------------- ServletRequest Methods | | 333 | | // ------------------------------------------------- ServletRequest Methods |
| 333 | | | | 334 | | | | 334 | | |
| 334 | | | | 335 | | | | 335 | | |
| 335 | | /** | | 336 | | /** | | 336 | | /** |
| 336 | | * Return the Internet Protocol (IP) address of the client that sent | | 337 | | * Return the Internet Protocol (IP) address of the client that sent | | 337 | | * Return the Internet Protocol (IP) address of the client that sent |
| 337 | | * this request. | | 338 | | * this request. | | 338 | | * this request. |
| 338 | | */ | | 339 | | */ | | 339 | | */ |
| 339 | | public String getRemoteAddr() { | | 340 | | public String getRemoteAddr() { | | 340 | | public String getRemoteAddr() { |
| 340 | | | | 341 | | | | 341 | | |
| 341 | | return (inet.getHostAddress()); | | 342 | | return (inet.getHostAddress()); | | 342 | | return (inet.getHostAddress()); |
| 342 | | | | 343 | | | | 343 | | |
| 343 | | } | | 344 | | } | | 344 | | } |
| 344 | | | | 345 | | | | 345 | | |
| 345 | | | | 346 | | | | 346 | | |
| 346 | | /** | | 347 | | /** | | 347 | | /** |
| 347 | | * Return the fully qualified name of the client that sent this request, | | 348 | | * Return the fully qualified name of the client that sent this request, | | 348 | | * Return the fully qualified name of the client that sent this request, |
| 348 | | * or the IP address of the client if the name cannot be determined. | | 349 | | * or the IP address of the client if the name cannot be determined. | | 349 | | * or the IP address of the client if the name cannot be determined. |
| 349 | | */ | | 350 | | */ | | 350 | | */ |
| 350 | | public String getRemoteHost() { | | 351 | | public String getRemoteHost() { | | 351 | | public String getRemoteHost() { |
| 351 | | | | 352 | | | | 352 | | |
| 352 | | if (connector.getEnableLookups()) | | 353 | | if (connector.getEnableLookups()) | | 353 | | if (connector.getEnableLookups()) |
| 353 | | return (inet.getHostName()); | | 354 | | return (inet.getHostName()); | | 354 | | return (inet.getHostName()); |
| 354 | | else | | 355 | | else | | 355 | | else |
| 355 | | return (getRemoteAddr()); | | 356 | | return (getRemoteAddr()); | | 356 | | return (getRemoteAddr()); |
| 356 | | | | 357 | | | | 357 | | |
| 357 | | } | | 358 | | } | | 358 | | } |
| 358 | | | | 359 | | | | 359 | | |
| 359 | | | | 360 | | | | 360 | | |
| 360 | | // --------------------------------------------- HttpServletRequest Methods | | 361 | | // --------------------------------------------- HttpServletRequest Methods | | 361 | | // --------------------------------------------- HttpServletRequest Methods |
| 361 | | | | 362 | | | | 362 | | |
| 362 | | | | 363 | | | | 363 | | |
| 363 | | /** | | 364 | | /** | | 364 | | /** |
| 364 | | * Return the first value of the specified header, if any; otherwise, | | 365 | | * Return the first value of the specified header, if any; otherwise, | | 365 | | * Return the first value of the specified header, if any; otherwise, |
| 365 | | * return <code>null</code> | | 366 | | * return <code>null</code> | | 366 | | * return <code>null</code> |
| 366 | | * | | 367 | | * | | 367 | | * |
| 367 | | * @param name Name of the requested header | | 368 | | * @param name Name of the requested header | | 368 | | * @param name Name of the requested header |
| 368 | | */ | | 369 | | */ | | 369 | | */ |
| 369 | | public String getHeader(String name) { | | 370 | | public String getHeader(String name) { | | 370 | | public String getHeader(String name) { |
| 370 | | | | 371 | | | | 371 | | |
| 371 | | name = name.toLowerCase(); | | 372 | | name = name.toLowerCase(); | | 372 | | name = name.toLowerCase(); |
| 372 | | for (int i = 0; i < nextHeader; i++) { | | 373 | | for (int i = 0; i < nextHeader; i++) { | | 373 | | for (int i = 0; i < nextHeader; i++) { |
| 373 | | if (headerPool[i].equals(name)) | | 374 | | if (headerPool[i].equals(name)) | | 374 | | if (headerPool[i].equals(name)) |
| 374 | | return new String(headerPool[i].value, 0, | | 375 | | return new String(headerPool[i].value, 0, | | 375 | | return new String(headerPool[i].value, 0, |
| 375 | | headerPool[i].valueEnd); | | 376 | | headerPool[i].valueEnd); | | 376 | | headerPool[i].valueEnd); |
| 376 | | } | | 377 | | } | | 377 | | } |
| 377 | | return null; | | 378 | | return null; | | 378 | | return null; |
| 378 | | | | 379 | | | | 379 | | |
| 379 | | | | 380 | | | | 380 | | |
| 380 | | } | | 381 | | } | | 381 | | } |
| 381 | | | | 382 | | | | 382 | | |
| 382 | | | | 383 | | | | 383 | | |
| 383 | | /** | | 384 | | /** | | 384 | | /** |
| 384 | | * Return all of the values of the specified header, if any; otherwise, | | 385 | | * Return all of the values of the specified header, if any; otherwise, | | 385 | | * Return all of the values of the specified header, if any; otherwise, |
| 385 | | * return an empty enumeration. | | 386 | | * return an empty enumeration. | | 386 | | * return an empty enumeration. |
| 386 | | * | | 387 | | * | | 387 | | * |
| 387 | | * @param name Name of the requested header | | 388 | | * @param name Name of the requested header | | 388 | | * @param name Name of the requested header |
| 388 | | */ | | 389 | | */ | | 389 | | */ |
| 389 | | public Enumeration getHeaders(String name) { | | 390 | | public Enumeration getHeaders(String name) { | | 390 | | public Enumeration getHeaders(String name) { |
| 390 | | | | 391 | | | | 391 | | |
| 391 | | name = name.toLowerCase(); | | 392 | | name = name.toLowerCase(); | | 392 | | name = name.toLowerCase(); |
| 392 | | ArrayList tempArrayList = new ArrayList(); | | 393 | | ArrayList tempArrayList = new ArrayList(); | | 393 | | ArrayList tempArrayList = new ArrayList(); |
| 393 | | for (int i = 0; i < nextHeader; i++) { | | 394 | | for (int i = 0; i < nextHeader; i++) { | | 394 | | for (int i = 0; i < nextHeader; i++) { |
| 394 | | if (headerPool[i].equals(name)) | | 395 | | if (headerPool[i].equals(name)) | | 395 | | if (headerPool[i].equals(name)) |
| 395 | | tempArrayList.add(new String(headerPool[i].value, 0, | | 396 | | tempArrayList.add(new String(headerPool[i].value, 0, | | 396 | | tempArrayList.add(new String(headerPool[i].value, 0, |
| 396 | | headerPool[i].valueEnd)); | | 397 | | headerPool[i].valueEnd)); | | 397 | | headerPool[i].valueEnd)); |
| 397 | | } | | 398 | | } | | 398 | | } |
| 398 | | return (Enumeration) new Enumerator(tempArrayList); | | 399 | | return (Enumeration) new Enumerator(tempArrayList); | | 399 | | return (Enumeration) new Enumerator(tempArrayList); |
| 399 | | | | 400 | | | | 400 | | |
| 400 | | } | | 401 | | } | | 401 | | } |
| 401 | | | | 402 | | | | 402 | | |
| 402 | | | | 403 | | | | 403 | | |
| 403 | | /** | | 404 | | /** | | 404 | | /** |
| 404 | | * Return the names of all headers received with this request. | | 405 | | * Return the names of all headers received with this request. | | 405 | | * Return the names of all headers received with this request. |
| 405 | | */ | | 406 | | */ | | 406 | | */ |
| 406 | | public Enumeration getHeaderNames() { | | 407 | | public Enumeration getHeaderNames() { | | 407 | | public Enumeration getHeaderNames() { |
| 407 | | ArrayList tempArrayList = new ArrayList(); | | 408 | | ArrayList tempArrayList = new ArrayList(); | | 408 | | ArrayList tempArrayList = new ArrayList(); |
| 408 | | for (int i = 0; i < nextHeader; i++) { | | 409 | | for (int i = 0; i < nextHeader; i++) { | | 409 | | for (int i = 0; i < nextHeader; i++) { |
| 409 | | tempArrayList.add(new String(headerPool[i].name, 0, | | 410 | | tempArrayList.add(new String(headerPool[i].name, 0, | | 410 | | tempArrayList.add(new String(headerPool[i].name, 0, |
| 410 | | headerPool[i].nameEnd)); | | 411 | | headerPool[i].nameEnd)); | | 411 | | headerPool[i].nameEnd)); |
| 411 | | } | | 412 | | } | | 412 | | } |
| 412 | | return (Enumeration) new Enumerator(tempArrayList); | | 413 | | return (Enumeration) new Enumerator(tempArrayList); | | 413 | | return (Enumeration) new Enumerator(tempArrayList); |
| 413 | | | | 414 | | | | 414 | | |
| 414 | | } | | 415 | | } | | 415 | | } |
| 415 | | | | 416 | | | | 416 | | |
| 416 | | } | | 417 | | } | | 417 | | } |