KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > server > httpd > HttpRequest


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "OpenEJB" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of The OpenEJB Group. For written permission,
18  * please contact openejb@openejb.org.
19  *
20  * 4. Products derived from this Software may not be called "OpenEJB"
21  * nor may "OpenEJB" appear in their names without prior written
22  * permission of The OpenEJB Group. OpenEJB is a registered
23  * trademark of The OpenEJB Group.
24  *
25  * 5. Due credit should be given to the OpenEJB Project
26  * (http://openejb.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
42  *
43  * $Id: HttpRequest.java,v 1.4 2005/04/05 08:05:06 dblevins Exp $
44  */

45 package org.openejb.server.httpd;
46
47 import java.io.IOException JavaDoc;
48 import java.io.InputStream JavaDoc;
49 import java.util.Map JavaDoc;
50 import java.net.URI JavaDoc;
51 import javax.servlet.ServletInputStream JavaDoc;
52
53
54 /** An interface to take care of HTTP Requests. It parses headers, content, form and url
55  * parameters.
56  *
57  */

58 public interface HttpRequest extends java.io.Serializable JavaDoc{
59     
60     /** the HTTP OPTIONS type */
61     public static final int OPTIONS = 0; // Section 9.2
62
/** the HTTP GET type */
63     public static final int GET = 1; // Section 9.3
64
/** the HTTP HEAD type */
65     public static final int HEAD = 2; // Section 9.4
66
/** the HTTP POST type */
67     public static final int POST = 3; // Section 9.5
68
/** the HTTP PUT type */
69     public static final int PUT = 4; // Section 9.6
70
/** the HTTP DELETE type */
71     public static final int DELETE = 5; // Section 9.7
72
/** the HTTP TRACE type */
73     public static final int TRACE = 6; // Section 9.8
74
/** the HTTP CONNECT type */
75     public static final int CONNECT = 7; // Section 9.9
76
/** the HTTP UNSUPPORTED type */
77     public static final int UNSUPPORTED = 8;
78     
79     /*
80      * Header variables
81      */

82     /** the Accept header */
83     public static final String JavaDoc HEADER_ACCEPT = "Accept";
84     /** the Accept-Encoding header */
85     public static final String JavaDoc HEADER_ACCEPT_ENCODING = "Accept-Encoding";
86     /** the Accept-Language header */
87     public static final String JavaDoc HEADER_ACCEPT_LANGUAGE = "Accept-Language";
88     /** the Content-Type header */
89     public static final String JavaDoc HEADER_CONTENT_TYPE = "Content-Type";
90     /** the Content-Length header */
91     public static final String JavaDoc HEADER_CONTENT_LENGTH = "Content-Length";
92     /** the Connection header */
93     public static final String JavaDoc HEADER_CONNECTION = "Connection";
94     /** the Cache-Control header */
95     public static final String JavaDoc HEADER_CACHE_CONTROL = "Cache-Control";
96     /** the Host header */
97     public static final String JavaDoc HEADER_HOST = "Host";
98     /** the User-Agent header */
99     public static final String JavaDoc HEADER_USER_AGENT = "User-Agent";
100     /** the Set-Cookie header */
101     public static final String JavaDoc HEADER_SET_COOKIE = "Set-Cookie";
102     /** the Cookie header */
103     public static final String JavaDoc HEADER_COOKIE = "Cookie";
104
105     /**
106      * Gets a form or URL query parameter based on the name passed in.
107      * @param name
108      */

109     String JavaDoc getParameter(String JavaDoc name);
110
111     /**
112      * Gets all the form and URL query parameters
113      * @return All the form and URL query parameters
114      */

115     Map JavaDoc getParameters();
116
117     /**
118      * Returns the current <code>HttpSession</code> associated with this
119      * request or, if there is no current session and <code>create</code> is
120      * true, returns a new session.
121      *
122      * <p>If <code>create</code> is <code>false</code> and the request has no
123      * valid <code>HttpSession</code>, this method returns <code>null</code>.
124      *
125      * @param create <code>true</code> to create a new session for this request
126      * if necessary; <code>false</code> to return <code>null</code> if there's
127      * no current session
128      *
129      * @return the <code>HttpSession</code> associated with this request or
130      * <code>null</code> if <code>create</code> is <code>false</code> and the
131      * request has no valid session
132      *
133      * @see #getSession()
134      */

135     public HttpSession getSession(boolean create);
136
137     /**
138      * Returns the current session associated with this request, or if the
139      * request does not have a session, creates one.
140      *
141      * @return the <code>HttpSession</code> associated with this request
142      *
143      * @see #getSession(boolean)
144      */

145     public HttpSession getSession();
146     
147     /** Gets a header based the header name passed in.
148      * @param name The name of the header to get
149      * @return The value of the header
150      */

151     public String JavaDoc getHeader(String JavaDoc name);
152
153     /** Gets an integer value of the request method. These values are:
154      *
155      * OPTIONS = 0
156      * GET = 1
157      * HEAD = 2
158      * POST = 3
159      * PUT = 4
160      * DELETE = 5
161      * TRACE = 6
162      * CONNECT = 7
163      * UNSUPPORTED = 8
164      * @return The integer value of the method
165      */

166     public int getMethod();
167
168     /** Gets the URI for the current URL page.
169      * @return The URI
170      */

171     public java.net.URI JavaDoc getURI();
172
173     int getContentLength();
174
175     String JavaDoc getContentType();
176
177     InputStream JavaDoc getInputStream() throws IOException JavaDoc;
178
179     public Object JavaDoc getAttribute(String JavaDoc name);
180
181     public void setAttribute(String JavaDoc name, Object JavaDoc value);
182
183 }
184
Popular Tags