[bknr-devel] Directory Handler problem

Thomas Karolski thomas.karolski at googlemail.com
Tue Jun 9 20:26:07 UTC 2009


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




More information about the Bknr-devel mailing list