On 01/13/2016 07:46 AM, RdR wrote:
> I encountered a problem porting http server code from Windows to Linux.
>
> An example:
>
> % test server
> :- use_module(library(http/thread_httpd)).
> :- use_module(library(http/http_dispatch)).
> :- use_module(library(http/http_files)).
> :- use_module(library(http/html_write)).
>
> :- http_handler(root(.), hello,[prefix]).
> :- http_handler(root(pages), http_reply_from_files(pages,[]),[prefix]).
>
> server:- http_server(http_dispatch,[port(8080)]).
>
> hello(_Request):-
> reply_html_page(title('Hello World'),[h1('Hello World')]).
>
> The "hello world" is displayed correctly on both Windows and Linux, but
> a file in the pages directory has problems in Linux.
>
> In Windows, assuming I have a file ("test.htm") in the sub-directory
> "pages", then the URL
http://localhost:8080/pages/test.htm will show the
> contents of the file. But on Linux, I get the following error:
>
>
> Internal server error
>
> No permission to read file `'/test.htm''
>
>
> The sub-directory "pages" has permission 755 (read and execute) and the
> file has permission 644 (read). I've tried other permissions, but still
> no success.
Read carefully! It says "/test.htm", note the "/". Now I have no clue why
this works on Windows, but you do need a rule like this binding the alias
to a physical location.
user:file_search_path(pages, pages).
If you need to debug this, run ?- tspy(http_reply_from_files). and reload
the page. That should bring up the graphical debugger, allowing you to
inspect the search.
Cheers --- Jan
>
> The test server program is executed from the directory above "pages" by
> the same user as the owner of the directories, by starting swipl and
> then loading the program and executing "server." at the prolog command
> prompt.
>
> Any ideas on how to resolve this?
>
> cheers,
>
> RdR
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
swi-prolog+...@googlegroups.com
> <mailto:
swi-prolog+...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/swi-prolog.
> For more options, visit
https://groups.google.com/d/optout.