[bknr-devel] Directory Handler problem

Hans Hübner hans.huebner at gmail.com
Tue Jun 9 20:43:40 UTC 2009


I think that DIRECTORY-HANDLER does not currently support being
mounted under the root directory, basically because it assumes that it
can safely strip the first character of the file path or some such.
It should not be too hard to fix this by special casing mounts under
the root directory, but I currently have no time to do that myself.
I'd look at a patch, though.

-Hans

On Tue, Jun 9, 2009 at 16:26, Thomas
Karolski<thomas.karolski at googlemail.com> wrote:
> Hey there,
> the directory handler is deleting the first char of every file which
> is dispatched through it (e.g. "http://localhost/example-3.lisp" accesses "/xample-3.lisp").
> I have the following simple example for a directory handler:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;; example-3.lisp ---
> (defpackage :example-3
>  (:use :cl :bknr.web :bknr.datastore))
>
> (in-package :example-3)
>
> (make-instance 'website
>                 :name "My first website"
>                 :handler-definitions `(("/" directory-handler
>                                             :destination #p"/home/thomas/workspace/bknr-examples/")))
>
> (defvar *server* nil)
> (if *server*
>    (progn
>      ;; Open a store
>      (close-store)
>      (make-instance 'mp-store :directory "store/"
>                     :subsystems (list (make-instance 'store-object-subsystem)))
>      ;; Create an anonymous user if none exists yet
>      (unless (bknr.user:find-user "anonymous")
>        (bknr.user:make-user "anonymous"))
>      (hunchentoot:stop *server*)
>      (setf hunchentoot:*show-lisp-errors-p* t)
>      (setf *server* nil))
>    (setf *server*
>          (hunchentoot:start (make-instance 'hunchentoot:acceptor :port 8080 :request-dispatcher 'bknr.web:bknr-dispatch))))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;; example-3.lisp ends here
>
> However, whenever I try to access http://localhost:8080/example-3.lisp
> (which also resides in the bknr-examples directory as specified in the
> :directory argument),
> I get the following error:
>
> ---------------------------------------------------------------------
> Internal Server Error
>
> FILES-NOT-FOUND while processing pathnames argument xample-3.lisp, files ("xample-3.lisp") could not be found
>
> Hunchentoot 1.0.0 (SBCL 1.0.28) at localhost:8080
> ---------------------------------------------------------------------
>
> For some reason "example-3.lisp" is truncated down to "xample-3.lisp". I
> tracked it down to 'request-relative-pathnames' in
> bknr/web/src/web/handlers.lisp.
> For some reason pathnames-argument is being let* with:
> (subseq (script-name*) (1+ (length (page-handler-prefix handler))))
> whereas '(script-name*)' returns "/example-3.lisp",
> and '(page-handler-prefix handler)' returns "/".
> With (length (page-handler-prefix handler)) being 1 and another 1 being
> added through 1+ we would get:
> (subseq "/example-3.lisp" 2)
> which results in "xsample-3.lisp" instead of "example-3.lisp".
>
> In case the 1+ is supposed to be there - what am I doing wrong when
> initializing the directory handler?
>
> Kind regards,
> Thomas
>
> _______________________________________________
> bknr-devel mailing list
> bknr-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/bknr-devel
>




More information about the Bknr-devel mailing list