WebKit.HTTPRequest | index /usr/local/share/webware/WebKit/HTTPRequest.py

`HTTP requests`

Modules

``

Cookie WebUtils.FieldStorage | WebKit.HTTPResponse cgi | os sys | traceback

Classes

``

WebKit.Request.Request(WebKit.Message.Message)
  HTTPRequest

class HTTPRequest(WebKit.Request.Request)
`` | `A type of Message for HTTP requests.`

Method resolution order:
  HTTPRequest
  WebKit.Request.Request
  WebKit.Message.Message
  __builtin__.object

Methods defined here:

__init__(self, requestDict=None)

accept(self, which=None)
  `Return preferences as requested by the user agent.
  The accepted preferences are returned as a list of codes
  in the same order as they appeared in the header.
  In other words, the explicit weighting criteria are ignored.
  If you do not define otherwise which preferences you are
  interested in ('language', 'charset', 'encoding'), by default
  you will get the user preferences for the content types.`

adapterFileName(self)
  `Return the filesystem path of the adapter.
  Equivalent to the CGI variable SCRIPT_FILENAME.`

adapterName(self)
  `Return the name of the adapter as it appears in the URL.
  Example: '/WK' or '/WebKit.cgi'
  Does not reflect redirection by the webserver.
  Equivalent to the CGI variable SCRIPT_NAME.`

contextName(self)
  `Return the name of the context of this request.
  This isn't necessarily the same as the name of the directory
  containing the context.`

contextPath(self)
  `Return the portion of the URI that is the context of the request.`

cookie(self, name, default=<class 'MiscUtils.NoDefault'>)
  `Return the value of the specified cookie.`

cookies(self)
  `Return a dict of all cookies the client sent with this request.`

delField(self, name)

environ(self)
  `Get the environment for the request.`

extraURLPath(self)
  `Return additional path components in the URL.
  Only works if the Application.config setting "ExtraPathInfo"
  is set to true; otherwise you will get a page not found error.`

field(self, name, default=<class 'MiscUtils.NoDefault'>)

fieldStorage(self)

fields(self)

fsPath(self)
  `The filesystem path of the request according to the webserver.`

hasCookie(self, name)
  `Return whether a cookie with the given name exists.`

hasField(self, name)

hasValue(self, name)
  `Check whether there is a value with the given name.`

hostAndPort(self)
  `Return the hostname and port part from the URL of this request.`

htmlInfo(self)
  `Return a single HTML string that represents info().
  Useful for inspecting objects via web browsers.`

info(self)
  `Return request info.
  Return a list of tuples where each tuple has a key/label (a string)
  and a value (any kind of object).
  Values are typically atomic values such as numbers and strings or
  another list of tuples in the same fashion. This is for debugging only.`

isSecure(self)
  `Check whether this is a HTTPS connection.`

isSessionExpired(self)
  `Return whether the request originally had an expired session ID.
  Only works if the Application.config setting "IgnoreInvalidSession"
  is set to true; otherwise you get a canned error page on an invalid
  session, so your servlet never gets processed.`

method(self)
  `Return the HTTP request method (in all uppercase).
  Typically from the set GET, POST, PUT, DELETE, OPTIONS and TRACE.`

originalContextName(self)
  `Return the name of the original context before any forwarding.`

originalServlet(self)
  `Get original servlet before any forwarding.`

originalURI(self)
  `Get URI of the original servlet before any forwarding.`

originalURLPath(self)
  `Get URL path of the original servlet before any forwarding.`

parent = previousServlet(self)

parents = previousServlets(self)

pathInfo(self)
  `Return any extra path information as sent by the client.
  This is anything after the servlet name but before the query string.
  Equivalent to the CGI variable PATH_INFO.`

pathTranslated(self)
  `Return extra path information translated as file system path.
  This is the same as pathInfo() but translated to the file system.
  Equivalent to the CGI variable PATH_TRANSLATED.`

pop(self)
  `Pop URL path and servlet from the stack, returning the servlet.`

previousContextName(self)
  `Get the previous context name, if any.`

previousContextNames(self)
  `Get the list of all previous context names.`

previousServlet(self)
  `Get the servlet that passed this request to us, if any.`

previousServlets(self)
  `Get the list of all previous servlets.`

previousURI(self)
  `Get the previous URI, if any.`

previousURIs(self)
  `Get the list of all previous URIs.`

previousURLPath(self)
  `Get the previous URL path, if any.`

previousURLPaths(self)
  `Get the list of all previous URL paths.`

protocol(self)
  `Return the name and version of the protocol.`

push(self, servlet, url=None)
  `Push servlet and URL path on a stack, setting a new URL.`

queryString(self)
  `Return the query string portion of the URL for this request.
  Equivalent to the CGI variable QUERY_STRING.`

rawInput(self, rewind=False)
  `Get the raw input from the request.
  This gives you a file-like object for the data that was sent with
  the request (e.g., the body of a POST request, or the document
  uploaded in a PUT request).
  The file might not be rewound to the beginning if there was valid,
  form-encoded POST data. Pass rewind=True if you want to be sure
  you get the entire body of the request.`

remoteAddress(self)
  `Return a string containing the IP address of the client.`

remoteName(self)
  `Return the fully qualified name of the client that sent the request.
  Returns the IP address of the client if the name cannot be determined.`

remoteUser(self)
  `Always returns None since authentication is not yet supported.
  Take from CGI variable REMOTE_USER.`

requestID(self)
  `Return the request ID.
  The request ID is a serial number unique to this request
  (at least unique for one run of the AppServer).`

responseClass(self)

scheme(self)
  `Return the URI scheme of the request (http or https).`

serverDictionary(self)
  `Return a dictionary with the data the web server gave us.
  This data includes HTTP_HOST and HTTP_USER_AGENT, for example.`

serverPath(self)
  `Return the webserver URL path of this request.
  This is the URL that was actually received by the webserver
  before any rewriting took place.
  Same as serverURL, but without scheme and host.`

serverPathDir(self)
  `Return the directory of the webserver URL path.
  Same as serverPath, but removes the actual page.`

serverSideContextPath(self, path=None)
  `Return the absolute server-side path of the context of this request.
  If the optional path is passed in, then it is joined with the server
  side context directory to form a path relative to the object.
  This directory could be different from the result of serverSidePath()
  if the request is in a subdirectory of the main context directory.`

serverSidePath(self, path=None)
  `Return the absolute server-side path of the request.
  If the optional path is passed in, then it is joined with the
  server side directory to form a path relative to the object.`

serverURL(self, canonical=False)
  `Return the full Internet path to this request.
  This is the URL that was actually received by the webserver
  before any rewriting took place. If canonical is set to true,
  then the canonical hostname of the server is used if possible.
  The path is returned without any extra path info or query strings,
  i.e. http://www.my.own.host.com:8080/WebKit/TestPage.py`

serverURLDir(self)
  `Return the directory of the URL in full Internet form.
  Same as serverURL, but removes the actual page.`

servlet(self)
  `Get current servlet for this request.`

servletPath(self)
  `Return the base URL for the servlets, sans host.
  This is useful in cases when you are constructing URLs.
  See Testing/Main.py for an example use.
  Roughly equivalent to the CGI variable SCRIPT_NAME,
  but reflects redirection by the webserver.`

servletPathFromSiteRoot(self)
  `Return the "servlet path" of this servlet relative to the siteRoot.
  In other words, everything after the name of the context (if present).
  If you append this to the result of siteRoot() you get back to
  the current servlet. This is useful for saving the path to the current
  servlet in a database, for example.`

servletURI(self)
  `Return servlet URI without any query strings or extra path info.`

session(self)
  `Return the session associated with this request.
  The session is either as specified by sessionId() or newly created.
  This is a convenience for transaction.session()`

sessionId(self)
  `Return a string with the session ID specified by the client.
  Returns None if there is no session ID.`

setField(self, name, value)

setSessionExpired(self, sessionExpired)

setSessionId(self, sessionID, force=False)
  `Set the session ID.
  This needs to be called _before_ attempting to use the session.
  This would be useful if the session ID is being passed in through
  unusual means, for example via a field in an XML-RPC request.
  Pass in force=True if you want to force this session ID to be used
  even if the session doesn't exist. This would be useful in unusual
  circumstances where the client is responsible for creating the unique
  session ID rather than the server.
  Be sure to use only legal filename characters in the session ID --
  0-9, a-z, A-Z, _, -, and . are OK but everything else will be rejected,
  as will identifiers longer than 80 characters.
  (Without passing in force=True, a random session ID will be generated
  if that session ID isn't already present in the session store.)`

setURLPath(self, path)
  `Set the URL path of the request.
  If self._absolutepath is set, this refers to the filesystem path.
  There is rarely a need to do this. Proceed with caution.`

siteRoot(self)
  `Return the relative URL path of the home location.
  This includes all URL path components necessary to get back home
  from the current location.
  Examples:
  ''
  '../'
  '../../'
  You can use this as a prefix to a URL that you know is based off
  the home location. Any time you are in a servlet that may have been
  forwarded to from another servlet at a different level, you should
  prefix your URL's with this. That is, if servlet "Foo/Bar" forwards
  to "Qux", then the qux servlet should use siteRoot() to construct all
  links to avoid broken links. This works properly because this method
  computes the path based on the _original_ servlet, not the location
  of the servlet that you have forwarded to.`

siteRootFromCurrentServlet(self)
  `Return relative URL path to home seen from the current servlet.
  This includes all URL path components necessary to get back home
  from the current servlet (not from the original request).
  Similar to siteRoot() but instead, it returns the site root
  relative to the _current_ servlet, not the _original_ servlet.`

time(self)
  `Return the time that the request was received.`

uri(self)
  `Return the URI for this request (everything after the host name).
  This is the URL that was actually received by the webserver
  before any rewriting took place, including the query string.
  Equivalent to the CGI variable REQUEST_URI.`

uriWebKitRoot(self)
  `Return relative URL path of the WebKit root location.`

urlPath(self)
  `Return URL path without host, adapter and query string.
  For example, http://host/WebKit.cgi/Context/Servlet?x=1
  yields '/Context/Servlet'.
  If self._absolutepath is set, this refers to the filesystem path.`

urlPathDir(self)
  `Same as urlPath, but only gives the directory.`

value(self, name, default=<class 'MiscUtils.NoDefault'>)
  `Return the value with the given name.
  Values are fields or cookies.
  Use this method when you're field/cookie agnostic.`

Methods inherited from WebKit.Request.Request:

clearTransaction(self)

input(self)
  `Return a file-style object that the contents can be read from.
  # @@ 2000-05-03 ce: This is bogus. Disregard for now.`

localAddress(self)
  `Get local address.
  Returns a string containing the Internet Protocol (IP) address
  of the local host (e.g., the server) that received the request.`

localPort(self)
  `Get local port.
  Returns the port of the local host (e.g., the server)
  that received the request.`

setTransaction(self, trans)
  `Set a transaction container.`

timeStamp(self)
  `Return time() as a human readable string, useful for logging and debugging.`

transaction(self)
  `Get the transaction container.`

Static methods inherited from WebKit.Request.Request:

localName()
  `Get local name.
  Returns the fully qualified name of the local host (e.g., the server)
  that received the request.`

Methods inherited from WebKit.Message.Message:

arg(self, name, default=<class 'MiscUtils.NoDefault'>)

argNames(self)
  `Return a list of argument names.`

clearArgs(self)

deleteArg(self, name)

hasArg(self, name)

setArg(self, name, value)

writeExceptionReport(self, handler)

Static methods inherited from WebKit.Message.Message:

contentLength()
  `Return the length of the message body or -1 if not known.`

contentType()
  `Return the MIME type of the message body or None if not known.`

Data descriptors inherited from WebKit.Message.Message:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

Functions

``

htmlInfo(info)
  `Return a single HTML string that represents the info structure.
  Useful for inspecting objects via web browsers.`

time(...)
  `time() -> floating point number
  Return the current time in seconds since the Epoch.
  Fractions of a second may be present if the system clock provides them.`

Data
`` |  | debug = False