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.server.httpd;
017:
018: import java.io.IOException;
019: import java.io.InputStream;
020: import java.util.Map;
021:
022: /** An interface to take care of HTTP Requests. It parses headers, content, form and url
023: * parameters.
024: *
025: */
026: public interface HttpRequest extends java.io.Serializable {
027: /**
028: * Request methods
029: */
030: public static enum Method {
031: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT, UNSUPPORTED
032: }
033:
034: //
035: // Header variables
036: //
037: /** the Accept header */
038: public static final String HEADER_ACCEPT = "Accept";
039: /** the Accept-Encoding header */
040: public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
041: /** the Accept-Language header */
042: public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
043: /** the Content-Type header */
044: public static final String HEADER_CONTENT_TYPE = "Content-Type";
045: /** the Content-Length header */
046: public static final String HEADER_CONTENT_LENGTH = "Content-Length";
047: /** the Connection header */
048: public static final String HEADER_CONNECTION = "Connection";
049: /** the Cache-Control header */
050: public static final String HEADER_CACHE_CONTROL = "Cache-Control";
051: /** the Host header */
052: public static final String HEADER_HOST = "Host";
053: /** the User-Agent header */
054: public static final String HEADER_USER_AGENT = "User-Agent";
055: /** the Set-Cookie header */
056: public static final String HEADER_SET_COOKIE = "Set-Cookie";
057: /** the Cookie header */
058: public static final String HEADER_COOKIE = "Cookie";
059:
060: //
061: // Common attrobute values
062: //
063: /**
064: * If the https server implementation is based on Servlets, the real HttpServletRequest
065: * will be registered in the request attributes using this name.
066: */
067: public static final String SERVLET_REQUEST = HttpRequest.class
068: .getName()
069: + "@ServletRequest";
070:
071: /**
072: * If the https server implementation is based on Servlets, the real HttpServletResponse
073: * will be registered in the request attributes using this name.
074: */
075: public static final String SERVLET_RESPONSE = HttpRequest.class
076: .getName()
077: + "@ServletResponse";
078:
079: /**
080: * If the https server implementation is based on Servlets, the real ServletContext
081: * will be registered in the request attributes using this name. Note: a ServletContext
082: * may not be registered even if HttpServletRequest and HttpServletResponse objects are
083: * registered.
084: */
085: public static final String SERVLET_CONTEXT = HttpRequest.class
086: .getName()
087: + "@ServletContext";
088:
089: /**
090: * Gets a form or URL query parameter based on the name passed in.
091: * @param name
092: */
093: String getParameter(String name);
094:
095: /**
096: * Gets all the form and URL query parameters
097: * @return All the form and URL query parameters
098: */
099: Map getParameters();
100:
101: /**
102: * Returns the current <code>HttpSession</code> associated with this
103: * request or, if there is no current session and <code>create</code> is
104: * true, returns a new session.
105: *
106: * <p>If <code>create</code> is <code>false</code> and the request has no
107: * valid <code>HttpSession</code>, this method returns <code>null</code>.
108: *
109: * @param create <code>true</code> to create a new session for this request
110: * if necessary; <code>false</code> to return <code>null</code> if there's
111: * no current session
112: *
113: * @return the <code>HttpSession</code> associated with this request or
114: * <code>null</code> if <code>create</code> is <code>false</code> and the
115: * request has no valid session
116: *
117: * @see #getSession()
118: */
119: public HttpSession getSession(boolean create);
120:
121: /**
122: * Returns the current session associated with this request, or if the
123: * request does not have a session, creates one.
124: *
125: * @return the <code>HttpSession</code> associated with this request
126: *
127: * @see #getSession(boolean)
128: */
129: public HttpSession getSession();
130:
131: /** Gets a header based the header name passed in.
132: * @param name The name of the header to get
133: * @return The value of the header
134: */
135: public String getHeader(String name);
136:
137: /** Gets an integer value of the request method.
138: * @return The integer value of the method
139: */
140: public Method getMethod();
141:
142: /** Gets the URI for the current URL page.
143: * @return The URI
144: */
145: public java.net.URI getURI();
146:
147: int getContentLength();
148:
149: String getContentType();
150:
151: InputStream getInputStream() throws IOException;
152:
153: public Object getAttribute(String name);
154:
155: public void setAttribute(String name, Object value);
156:
157: String getRemoteAddr();
158: }
|