001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.webadmin;
017:
018: /** An interface to take care of HTTP Requests. It parses headers, content, form and url
019: * parameters.
020: *
021: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
022: */
023: public interface HttpRequest extends java.io.Serializable {
024:
025: /** the HTTP OPTIONS type */
026: public static final int OPTIONS = 0; // Section 9.2
027: /** the HTTP GET type */
028: public static final int GET = 1; // Section 9.3
029: /** the HTTP HEAD type */
030: public static final int HEAD = 2; // Section 9.4
031: /** the HTTP POST type */
032: public static final int POST = 3; // Section 9.5
033: /** the HTTP PUT type */
034: public static final int PUT = 4; // Section 9.6
035: /** the HTTP DELETE type */
036: public static final int DELETE = 5; // Section 9.7
037: /** the HTTP TRACE type */
038: public static final int TRACE = 6; // Section 9.8
039: /** the HTTP CONNECT type */
040: public static final int CONNECT = 7; // Section 9.9
041: /** the HTTP UNSUPPORTED type */
042: public static final int UNSUPPORTED = 8;
043:
044: /*
045: * Header variables
046: */
047: /** the Accept header */
048: public static final String HEADER_ACCEPT = "Accept";
049: /** the Accept-Encoding header */
050: public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
051: /** the Accept-Language header */
052: public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
053: /** the Content-Type header */
054: public static final String HEADER_CONTENT_TYPE = "Content-Type";
055: /** the Content-Length header */
056: public static final String HEADER_CONTENT_LENGTH = "Content-Length";
057: /** the Connection header */
058: public static final String HEADER_CONNECTION = "Connection";
059: /** the Cache-Control header */
060: public static final String HEADER_CACHE_CONTROL = "Cache-Control";
061: /** the Host header */
062: public static final String HEADER_HOST = "Host";
063: /** the User-Agent header */
064: public static final String HEADER_USER_AGENT = "User-Agent";
065: /** the Set-Cookie header */
066: public static final String HEADER_SET_COOKIE = "Set-Cookie";
067: /** the Cookie header */
068: public static final String HEADER_COOKIE = "Cookie";
069:
070: /**
071: * Returns the current <code>HttpSession</code> associated with this
072: * request or, if there is no current session and <code>create</code> is
073: * true, returns a new session.
074: *
075: * <p>If <code>create</code> is <code>false</code> and the request has no
076: * valid <code>HttpSession</code>, this method returns <code>null</code>.
077: *
078: * @param create <code>true</code> to create a new session for this request
079: * if necessary; <code>false</code> to return <code>null</code> if there's
080: * no current session
081: *
082: * @return the <code>HttpSession</code> associated with this request or
083: * <code>null</code> if <code>create</code> is <code>false</code> and the
084: * request has no valid session
085: *
086: * @see #getSession()
087: */
088: public HttpSession getSession(boolean create);
089:
090: /**
091: * Returns the current session associated with this request, or if the
092: * request does not have a session, creates one.
093: *
094: * @return the <code>HttpSession</code> associated with this request
095: *
096: * @see #getSession(boolean)
097: */
098: public HttpSession getSession();
099:
100: /** Gets a header based the header name passed in.
101: * @param name The name of the header to get
102: * @return The value of the header
103: */
104: public String getHeader(String name);
105:
106: /** Gets a form parameter based on the name passed in.
107: * @param name The name of the form parameter to get
108: * @return The value of the parameter
109: */
110: public String getFormParameter(String name);
111:
112: /** Gets all the form parameters in the form of a two-dimentional array
113: * The second dimention has two indexes which contain the key and value
114: * for example:
115: * <code>
116: * for(int i=0; i<formParams.length; i++) {
117: * key = formParams[i][0];
118: * value = formParams[i][1];
119: * }
120: * </code>
121: *
122: * All values are strings
123: * @return All the form parameters
124: */
125: public String[][] getFormParameters();
126:
127: /** Gets a URL (or query) parameter based on the name passed in.
128: * @param name The name of the URL (or query) parameter
129: * @return The value of the URL (or query) parameter
130: */
131: public String getQueryParameter(String name);
132:
133: /** Gets an integer value of the request method. These values are:
134: *
135: * OPTIONS = 0
136: * GET = 1
137: * HEAD = 2
138: * POST = 3
139: * PUT = 4
140: * DELETE = 5
141: * TRACE = 6
142: * CONNECT = 7
143: * UNSUPPORTED = 8
144: * @return The integer value of the method
145: */
146: public int getMethod();
147:
148: /** Gets the URI for the current URL page.
149: * @return The URI
150: */
151: public java.net.URL getURI();
152:
153: }
|