de.oio.bugkilla.protocol
Class HttpRequest

java.lang.Object
  |
  +--de.oio.bugkilla.protocol.HttpRequest
All Implemented Interfaces:
java.io.Serializable

public class HttpRequest
extends java.lang.Object
implements java.io.Serializable

Represent one HttpRequest-Object

Author:
swinkler
See Also:
TestStep, Serialized Form

Constructor Summary
HttpRequest()
          Construct a new HttpRequest
HttpRequest(java.lang.String name)
          Construct a new HttpRequest with a specified name
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration containing the names of the attributes available to this request.
 java.util.Hashtable getAttributes()
          Returns the attributes of this request as Hashtable
 java.lang.String getAuthType()
          Returns the name of the authentication scheme used to protect the servlet.
 java.lang.String getContentType()
          Returns the MIME type of the body of the request, or null if the type is not known.
 java.lang.String getContextPath()
          Returns the portion of the request URI that indicates the context of the request.
 Cookie getCookie(java.lang.String name)
          Returns a Cookie-object specified by its name
 java.util.Hashtable getCookies()
          Returns a Hashtable containing all of the Cookie objects the client sent with this request.
 java.lang.String getMethod()
          Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 java.lang.String getName()
          Returns the Identificationname of the HttpRequest
 java.lang.Object getParameter(java.lang.String name)
          Returns the value of a request parameter as a Object (String or String[]), or null if the parameter does not exist.
 java.util.Enumeration getParameterNames()
          Returns an Enumeration of String objects containing the names of the parameters contained in this request.
 java.util.Hashtable getParameters()
          Returns the parameters of this request as Hashtable
 java.lang.String getPathInfo()
          Returns any extra path information associated with the URL the client sent when it made this request.
 java.lang.String getProtocol()
          Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
 java.lang.String getQueryString()
          Returns the query string that is contained in the request URL after the path.
 java.lang.String getRemoteAddr()
          Returns the Internet Protocol (IP) address of the client that sent the request.
 java.lang.String getRemoteHost()
          Returns the fully qualified name of the client that sent the request.
 java.lang.String getRemoteUser()
          Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
 java.lang.String getRequestedSessionId()
          Returns the session ID specified by the client.
 java.lang.String getRequestURI()
          Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 java.lang.String getRequestURL()
          The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
 java.lang.String getScheme()
          Returns the name of the scheme used to make this request, for example, http, https, or ftp.
 java.lang.String getServerName()
          Returns the host name of the server that received the request.
 int getServerPort()
          Returns the port number on which this request was received.
 java.lang.String getServletPath()
          Returns the part of this request's URL that calls the servlet.
 HttpSession getSession()
          Returns the session associated with this request
 boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 void setAttribute(java.lang.String name, java.lang.Object obj)
          Sets an attribute of this request.
 void setAttributes(java.util.Hashtable attributes)
          Sets the attributes of this request as Hashtable.
 void setAuthType(java.lang.String authType)
          Sets the name of the authentication scheme used to protect the servlet.
 void setContentType(java.lang.String contentType)
          Sets the MIME type of the body of the request, or null if the type is not known.
 void setContextPath(java.lang.String contextPath)
          Sets the portion of the request URI that indicates the context of the request.
 void setCookie(java.lang.String name, Cookie cookie)
          Adds a Cookie (identifier of the Cookie ant the Cookie) at the Hashtable
 void setCookies(java.util.Hashtable cookies)
          Sets a Hashtable containing all of the Cookie objects the client sent with this request.
 void setMethod(java.lang.String method)
          Sets the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 void setName(java.lang.String name)
          Sets the Identificationname of the HttpRequest
 void setParameter(java.lang.String name, java.lang.Object obj)
          Also obj can be a String[] containing more than 1 value for the parameter
 void setParameters(java.util.Hashtable parameters)
          Sets the parameters of this request as Hashtable.
 void setPathInfo(java.lang.String pathInfo)
          Sets any extra path information associated with the URL the client sent when it made this request.
 void setProtocol(java.lang.String protocol)
          Sets the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
 void setQueryString(java.lang.String queryString)
          Sets the query string that is contained in the request URL after the path.
 void setRemoteAddr(java.lang.String remoteAddr)
          Sets the Internet Protocol (IP) address of the client that sent the request.
 void setRemoteHost(java.lang.String remoteHost)
          Sets the fully qualified name of the client that sent the request.
 void setRemoteUser(java.lang.String remoteUser)
          Sets the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
 void setRequestedSessionId(java.lang.String requestedSessionId)
          Sets the session ID specified by the client.
 void setRequestURI(java.lang.String requestURI)
          Sets the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 void setRequestURL(java.lang.String requestURL)
          Sets the URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
 void setScheme(java.lang.String scheme)
          Sets the name of the scheme used to make this request, for example, http, https, or ftp.
 void setSecure(boolean isSecure)
          Sets a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 void setServerName(java.lang.String serverName)
          Sets the host name of the server that received the request.
 void setServerPort(int serverPort)
          Sets the port number on which this request was received.
 void setServletPath(java.lang.String servletPath)
          Sets the part of this request's URL that calls the servlet.
 void setSession(HttpSession session)
          Sets the session associated with this request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRequest

public HttpRequest(java.lang.String name)
Construct a new HttpRequest with a specified name

Parameters:
name - Name of the HttpRequest

HttpRequest

public HttpRequest()
Construct a new HttpRequest

Method Detail

getMethod

public java.lang.String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.

Returns:
the HTTP method of the HttpRequest

setMethod

public void setMethod(java.lang.String method)
Sets the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.

Parameters:
method - the HTTP method of the HttpRequest

getPathInfo

public java.lang.String getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string. This method returns null if there was no extra path information.
Same as the value of the CGI variable PATH_INFO.

Returns:
a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information

setPathInfo

public void setPathInfo(java.lang.String pathInfo)
Sets any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string. This method returns null if there was no extra path information.

Parameters:
pathInfo - a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information

getQueryString

public java.lang.String getQueryString()
Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.

Returns:
a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.

setQueryString

public void setQueryString(java.lang.String queryString)
Sets the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.

Parameters:
queryString - a String containing the query string

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Returns the session ID specified by the client. This may not be the same as the ID of the actual session in use. For example, if the request specified an old (expired) session ID and the server has started a new session, this method gets a new session with a new ID. If the request did not specify a session ID, this method returns null.

Returns:
a String specifying the session ID, or null if the request did not specify a session ID

setRequestedSessionId

public void setRequestedSessionId(java.lang.String requestedSessionId)
Sets the session ID specified by the client. This may not be the same as the ID of the actual session in use. For example, if the request specified an old (expired) session ID and the server has started a new session, this method gets a new session with a new ID. If the request did not specify a session ID, this method returns null.

Parameters:
requestedSessionId - a String specifying the session ID, or null if the request did not specify a session ID

getRequestURL

public java.lang.String getRequestURL()
The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Returns:
the requested URL

setRequestURL

public void setRequestURL(java.lang.String requestURL)
Sets the URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Parameters:
requestURL - the requested URL

getServletPath

public java.lang.String getServletPath()
Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME.

Returns:
a String containing the name or path of the servlet being called, as specified in the request URL, decoded.

setServletPath

public void setServletPath(java.lang.String servletPath)
Sets the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME.

Parameters:
servletPath - a String containing the name or path of the servlet being called, as specified in the request URL, decoded.

getRequestURI

public java.lang.String getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String.
For example:
First line of HTTP request Returned Value
POST /some/path.html HTTP/1.1/some/path.html
GET http://foo.bar/a.html HTTP/1.0/a.html
HEAD /xyz?a=b HTTP/1.1/xyz

Returns:
a String containing the part of the URL from the protocol name up to the query string

setRequestURI

public void setRequestURI(java.lang.String requestURI)
Sets the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String.
For example:
First line of HTTP request
POST /some/path.html HTTP/1.1
GET http://foo.bar/a.html HTTP/1.0
HEAD /xyz?a=b HTTP/1.1

Parameters:
requestURI - a String containing the part of the URL from the protocol name up to the query string

getRemoteUser

public java.lang.String getRemoteUser()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER.

Returns:
a String specifying the login of the user making this request, or null

setRemoteUser

public void setRemoteUser(java.lang.String remoteUser)
Sets the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER.

Parameters:
remoteUser - a String specifying the login of the user making this request, or null

getCookies

public java.util.Hashtable getCookies()
Returns a Hashtable containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.

Returns:
a Hashtable of all the Cookies included with this request, or null if the request has no cookies

setCookies

public void setCookies(java.util.Hashtable cookies)
Sets a Hashtable containing all of the Cookie objects the client sent with this request.

Parameters:
cookies - a Hashtable of all teh Cookies included with this request

getCookie

public Cookie getCookie(java.lang.String name)
Returns a Cookie-object specified by its name

Parameters:
name - the cookies name
Returns:
a Cookie-object

setCookie

public void setCookie(java.lang.String name,
                      Cookie cookie)
Adds a Cookie (identifier of the Cookie ant the Cookie) at the Hashtable

Parameters:
name - identifier of the Cookie
cookie - Cookie object

getContextPath

public java.lang.String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character.

Returns:
a String specifying the portion of the request URI that indicates the context of the request

setContextPath

public void setContextPath(java.lang.String contextPath)
Sets the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character.

Parameters:
contextPath - a String specifying the protion of the request URI that indicates the context of the request

getAuthType

public java.lang.String getAuthType()
Returns the name of the authentication scheme used to protect the servlet. All servlet containers support basic, form and client certificate authentication, and may additionally support digest authentication. If the servlet was not authenticated null is returned.

Returns:
has to return BASIC, FORM, CLIENT_CERT, DIGEST or NULL

setAuthType

public void setAuthType(java.lang.String authType)
Sets the name of the authentication scheme used to protect the servlet.
please use BASIC, FORM, CLIENT_CERT, DIGEST or NULL

Parameters:
authType - a String specifying the authentication scheme

setAttributes

public void setAttributes(java.util.Hashtable attributes)
Sets the attributes of this request as Hashtable.

Parameters:
attributes - the attributes of this request as Hashtable

getAttributes

public java.util.Hashtable getAttributes()
Returns the attributes of this request as Hashtable

Returns:
the attributes of this request as Hashtable

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object obj)
Sets an attribute of this request. Attributes are reset between requests.
Attribute names should follow the same conventions as package names. Names beginning with java.*, javax.*, and com.sun.*, are reserved for use by Sun Microsystems.

Parameters:
name - a String specifying the name of the attribute
obj - the Object to be stored

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute javax.servlet.request.X509Certificate can be used to retrieve information on the certificate of the client. Attributes can also be set programatically using setAttribute(java.lang.String, java.lang.Object). This allows information to be embedded into a request before a RequestDispatcher call.
Attribute names should follow the same conventions as package names. This specification reserves names matching java.*, javax.*, and sun.*.

Parameters:
name - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if the attribute does not exist

getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this request. This method returns an empty Enumeration if the request has no attributes available to it.

Returns:
an Enumeration of strings containing the names of the request's attributes

setParameters

public void setParameters(java.util.Hashtable parameters)
Sets the parameters of this request as Hashtable.

Parameters:
parameters - the parameters of this request as Hashtable

getParameters

public java.util.Hashtable getParameters()
Returns the parameters of this request as Hashtable

Returns:
the parameters of this request as Hashtable

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object obj)
Also obj can be a String[] containing more than 1 value for the parameter

Parameters:
name - a String specifying the name of the parameter
obj - a Object (String or String[]) representing the value of the parameter

getParameter

public java.lang.Object getParameter(java.lang.String name)
Returns the value of a request parameter as a Object (String or String[]), or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

Parameters:
name - a String specifying the name of the parameter
Returns:
a Object (String or String[]) representing the single value of the parameter

getParameterNames

public java.util.Enumeration getParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.

Returns:
an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters

getName

public java.lang.String getName()
Returns the Identificationname of the HttpRequest

Returns:
the Identificationname of the HttpRequest

setName

public void setName(java.lang.String name)
Sets the Identificationname of the HttpRequest

Parameters:
name - the Identificationname of the HttpRequest

getContentType

public java.lang.String getContentType()
Returns the MIME type of the body of the request, or null if the type is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE.

Returns:
a String containing the name of the MIME type of the request, or null if the type is not known

setContentType

public void setContentType(java.lang.String contentType)
Sets the MIME type of the body of the request, or null if the type is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE.

Parameters:
contentType - a String containing the name of the MIME type of the request, or null if the type is not known

getProtocol

public java.lang.String getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL

Returns:
a String containing the protocol name and version number

setProtocol

public void setProtocol(java.lang.String protocol)
Sets the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL

Parameters:
protocol - a String containing the protocol name and version number

getRemoteAddr

public java.lang.String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.

Returns:
a String containing the IP address of the client that sent the request

setRemoteAddr

public void setRemoteAddr(java.lang.String remoteAddr)
Sets the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.

Parameters:
remoteAddr - a String containing the IP address of the client that sent the request

getRemoteHost

public java.lang.String getRemoteHost()
Returns the fully qualified name of the client that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST.

Returns:
a String containing the fully qualified name of the client

setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
Sets the fully qualified name of the client that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST.

Parameters:
remoteHost - a String containing the fully qualified name of the client

getScheme

public java.lang.String getScheme()
Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.

Returns:
a String containing the name of the scheme used to make this request

setScheme

public void setScheme(java.lang.String scheme)
Sets the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.

Parameters:
scheme - a String containing the name of the scheme used to make this request

getServerName

public java.lang.String getServerName()
Returns the host name of the server that received the request. For HTTP servlets, same as the value of the CGI variable SERVER_NAME.

Returns:
a String containing the name of the server to which the request was sent

setServerName

public void setServerName(java.lang.String serverName)
Sets the host name of the server that received the request. For HTTP servlets, same as the value of the CGI variable SERVER_NAME.

Parameters:
serverName - a String containing the name of the server to which the request was sent

getServerPort

public int getServerPort()
Returns the port number on which this request was received. For HTTP servlets, same as the value of the CGI variable SERVER_PORT.

Returns:
an integer specifying the port number

setServerPort

public void setServerPort(int serverPort)
Sets the port number on which this request was received. For HTTP servlets, same as the value of the CGI variable SERVER_PORT.

Parameters:
serverPort - an integer specifying the port number

isSecure

public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Returns:
a boolean indicating if the request was made using a secure channel

setSecure

public void setSecure(boolean isSecure)
Sets a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Parameters:
isSecure - a boolean indicating if the request was made using a secure channel

getSession

public HttpSession getSession()
Returns the session associated with this request

Returns:
the HttpSession associated with this request

setSession

public void setSession(HttpSession session)
Sets the session associated with this request

Parameters:
session - the HttpSession associated with this request


Copyright © Orientation in Objects GmbH. All Rights Reserved.