Class WebApp
In: webapp.rb
webapp/cli.rb
webapp/htmlform.rb
webapp/manager.rb
webapp/message.rb
webapp/querystring.rb
webapp/urigen.rb
webapp/webrick-servlet.rb
Parent: Object

Copyright (c) 2006 Tanaka Akira. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

 1. Redistributions of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.
 3. The name of the author may not be used to endorse or promote products
    derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Methods

Classes and Modules

Class WebApp::HTMLFormQuery
Class WebApp::Manager
Class WebApp::QueryString
Class WebApp::QueryValidationFailure
Class WebApp::WEBrickServletHandler

Public Class methods

calls WebApp#reluri using the webapp object currently processing.

Public Instance methods

make_absolute_uri returns a absolute URI which base URI is the URI of the web application is invoked.

The argument is same as make_relative_uri.

 make_relative_uri returns a relative URI which base URI is the URI the
 web application is invoked.

 The argument should be a hash which may have following components.
 - :script specifies script_name relative from the directory containing
   the web application script.
   If it is not specified, the web application itself is assumed.
 - :path_info specifies path_info component for calling web application.
   It should begin with a slash.
   If it is not specified, "" is assumed.
 - :query specifies query a component.
   It should be a Hash or a WebApp::QueryString.
 - :fragment specifies a fragment identifier.
   If it is not specified, a fragment identifier is not appended to
   the result URL.

 Since the method escapes the components properly,
 you should specify them in unescaped form.

 In the example follow, assume that the web application bar.cgi is invoked
 as http://host/foo/bar.cgi/baz/qux.

   webapp.reluri(:path_info=>"/hoge") => URI("../hoge")
   webapp.reluri(:path_info=>"/baz/fuga") => URI("fuga")
   webapp.reluri(:path_info=>"/baz/") => URI("./")
   webapp.reluri(:path_info=>"/") => URI("../")
   webapp.reluri() => URI("../../bar.cgi")
   webapp.reluri(:script=>"funyo.cgi") => URI("../../funyo.cgi")
   webapp.reluri(:script=>"punyo/gunyo.cgi") => URI("../../punyo/gunyo.cgi")
   webapp.reluri(:script=>"../genyo.cgi") => URI("../../../genyo.cgi")
   webapp.reluri(:fragment=>"sec1") => URI("../../bar.cgi#sec1")

)

   webapp.reluri(:path_info=>"/h?#o/x y") => URI("../h%3F%23o/x%20y")
   webapp.reluri(:script=>"ho%o.cgi") => URI("../../ho%25o.cgi")
   webapp.reluri(:fragment=>"sp ce") => URI("../../bar.cgi#sp%20ce")

opens path as relative from a web application directory.

reluri(hash={})

Alias for make_relative_uri

returns a Pathname object. path is interpreted as a relative path from the directory which a web application exists.

If /home/user/public_html/foo/bar.cgi is a web application which WebApp {} calls, webapp.resource_path("baz") returns a pathname points to /home/user/public_html/foo/baz.

path must not have ".." component and must not be absolute. Otherwise ArgumentError is raised.

send the resource indicated by path. Last-Modified: and If-Modified-Since: header is supported.

setup_redirect makes a status line and a Location header appropriate as redirection.

status specifies the status line. It should be a Fixnum 3xx or String ‘3xx …’.

uri specifies the Location header body. It should be a URI, String or Hash. If a Hash is given, make_absolute_uri is called to convert to URI. If given URI is relative, it is converted as absolute URI.

[Validate]