rp_serve_abstract_file (private)

 rp_serve_abstract_file [ -noredirect ] [ -nodirectory ] \
    [ -extension_pattern extension_pattern ] path

Defined in packages/acs-tcl/tcl/request-processor-procs.tcl

Serves up a file given the abstract path. Raises the following exceptions in the obvious cases:

  • notfound (passes back an empty value)
  • redirect (passes back the url to which it wants to redirect)
  • directory (passes back the path of the directory)
Should not be used in .vuh files or elsewhere, instead use the public function rp_internal_redirect.

Switches:
-noredirect (optional, boolean)
-nodirectory (optional, boolean)
-extension_pattern (optional, defaults to ".*")
Parameters:
path (required)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 rp_handle_request rp_handle_request (private) rp_serve_abstract_file rp_serve_abstract_file rp_handle_request->rp_serve_abstract_file rp_internal_redirect rp_internal_redirect (public) rp_internal_redirect->rp_serve_abstract_file ad_conn ad_conn (public) rp_serve_abstract_file->ad_conn ad_file ad_file (public) rp_serve_abstract_file->ad_file ad_raise ad_raise (public) rp_serve_abstract_file->ad_raise rp_concrete_file rp_concrete_file (private) rp_serve_abstract_file->rp_concrete_file rp_serve_concrete_file rp_serve_concrete_file (public) rp_serve_abstract_file->rp_serve_concrete_file

Testcases:
No testcase defined.
Source code:
    if {[string index $path end] eq "/"} {
        if { [ad_file isdirectory $path] } {
            # The path specified was a directory; return its index file.

            # Directory name with trailing slash. Search for an index.* file.
            # Remember the name of the directory in $dir_index, so we can later
            # generate a directory listing if necessary.
            set dir_index $path
            set path "[string trimright $path /]/index"

        } else {

            # If there's a trailing slash on the path, the URL must refer to a
            # directory (which we know doesn't exist, since [ad_file isdirectory $path]
            # returned 0).
            ad_raise notfound
        }
    }

    ### no more trailing slash.

    if { [ad_file isfile $path] } {
        # It's actually a file.
        ad_conn -set file $path
    } else {
        # The path provided doesn't correspond directly to a file - we
        # need to glob.   (It could correspond directly to a directory.)

        if { ![file isdirectory [ad_file dirname $path]] } {
            ad_raise notfound
        }

        ad_conn -set file [rp_concrete_file -extension_pattern $extension_pattern $path]

        if { [ad_conn file] eq "" } {

            if { [ad_file isdirectory $path] && !$noredirect_p } {
                # Directory name with no trailing slash. Redirect to the same
                # URL but with a trailing slash.

                set url "[ad_conn url]/"
                if { [ad_conn query] ne "" } {
                    append url "?[ad_conn query]"
                }

                ad_raise redirect $url
            } else {
                if { [info exists dir_index] && !$nodirectory_p } {
                    ad_raise directory $dir_index
                } else {
                    # Nothing at all found! 404 time.
                    ad_raise notfound
                }
            }
        }
    }

    rp_serve_concrete_file [ad_conn file]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: