Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (44 sloc) 1.863 kb
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
1 -module(yaws_vdir).
2
3 -export([arg_rewrite/1]).
4
ca1c8b1 @karlsson Fixed a number of compiler warnings and html validation errors
karlsson authored
5 -include_lib("../include/yaws_api.hrl").
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
6
7 -export([join/2]).
8
9 join(List, Sep) ->
10 lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ Sep ++ A
11 end, "", List).
12
13
14 arg_rewrite(ARG) ->
15 Req = ARG#arg.req,
16 %%io:fwrite("----->rewrite_mod for request: ~p\n",[ARG#arg.req]),
17
18 case Req#http_request.path of
19 {abs_path, RawPath} ->
20 case (catch yaws_api:url_decode_q_split(RawPath)) of
455578a @vinoski major trailing whitespace cleanup
vinoski authored
21 {'EXIT', _} ->
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
22 %%broken request - ignore let yaws_server handle it.
23 ARG2 = ARG;
24 {"", _QueryPart} ->
25 ARG2 = ARG;
26 {"/", _QueryPart} ->
455578a @vinoski major trailing whitespace cleanup
vinoski authored
27 %%don't allow vdir to be specified for root -
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
28 %% it doesn't make sense
29 ARG2 = ARG;
30 {DecPath, _QueryPart} ->
31 SC = get(sc),
32
455578a @vinoski major trailing whitespace cleanup
vinoski authored
33 %%vdirpath/3 will return the longest(ie most specific)
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
34 %% 'virtual directory' match for our request
455578a @vinoski major trailing whitespace cleanup
vinoski authored
35 %%It retrieves the vdir definitions from #arg.opaque
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
36 case yaws_server:vdirpath(SC, ARG, DecPath) of
37 {"",_MainDocRoot} ->
455578a @vinoski major trailing whitespace cleanup
vinoski authored
38 %%no virtual dir corresponding to this
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
39 %% http_request.path
40
41 ARG2 = ARG;
42 {Virt,DocRoot} ->
43
455578a @vinoski major trailing whitespace cleanup
vinoski authored
44 %%the virtual-path of our request matches a
45 %% vdir specification
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
46 %% - rewrite ARG accordingly.
47
48 ARG2 = ARG#arg{docroot = DocRoot,
49 docroot_mount = Virt}
50 end
51 end;
52 _Else ->
53 ARG2 = ARG
455578a @vinoski major trailing whitespace cleanup
vinoski authored
54 end,
8176fe9 @klacke reintroduced yaws_vdir.erl, erroneoulsy removed
authored
55
56 ARG2.
57
Something went wrong with that request. Please try again.