public
Fork of KirinDave/fuzed
Description: A new revision of Fuzed, the Erlang-based frontend for web apps.
Clone URL: git://github.com/mojombo/fuzed.git
Search Repo:
Merge commit 'kirindave/master'
mojombo (author)
Sun May 04 11:56:31 -0700 2008
commit  294d1d617c8f26b4c4e4228aa5b7671e8c78a7ac
tree    c70e453eacc52eccb8fc8fedb301ebcc16e8892d
parent  ef7d1eb0d77cfc68b518e83fcae44777e4c97c3f parent  ce16b3f48b04638a9c7bbdb0a7e99b17f72f1997
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@
0
 require 'rake'
0
 
0
 ERLC_TEST_FLAGS = "-pa ../ebin/eunit -I .. -I ../etest -I ../include/eunit -DTEST"
0
-ERLC_FLAGS = "+debug_info -W2 -I ../include -I ../include/thrift -I ../include/yaws -o ../ebin"
0
+ERLC_FLAGS = "+debug_info -W2 -I ../include -I ../include/ -I ../include/yaws -o ../ebin"
0
 FUZED_VERSION = "0.4.13"
0
 
0
 task :default do
...
3
4
5
6
7
8
9
10
11
12
13
 
 
14
15
16
17
...
20
21
22
23
 
24
25
26
27
 
28
29
30
...
3
4
5
 
 
 
 
 
 
 
 
6
7
8
9
10
11
...
14
15
16
 
17
18
19
20
 
21
22
23
24
0
@@ -3,14 +3,8 @@
0
 require 'digest/md5'
0
 require 'resolv'
0
 
0
-if __FILE__ == "/p/bin/fuzed"
0
- $:.unshift(File.join("/p/libexec/erlang/fuzed/rlibs"))
0
- $:.unshift(File.join("/p/libexec/erlang/fuzed/rlibs/cli"))
0
- FUZED_ROOT = "/p/libexec/erlang/fuzed"
0
-else
0
- $:.unshift(File.join(File.dirname(__FILE__), *%w[.. rlibs]))
0
- FUZED_ROOT = File.join(File.dirname(__FILE__), *%w[..])
0
-end
0
+$:.unshift(File.join(File.dirname(__FILE__), *%w[.. rlibs]))
0
+FUZED_ROOT = File.join(File.dirname(__FILE__), *%w[..])
0
 
0
 CMD_LINE_PATH = File.join(FUZED_ROOT, *%w[rlibs cli])
0
 CMD_LINE_COMMANDS = Dir[CMD_LINE_PATH + "/*.rb"].map { |fname| File.basename(fname).split(".")[0].downcase }
0
0
@@ -20,11 +14,11 @@
0
 DEFAULT_NODE_NAME = `hostname -s`.chomp + "-#{rand(9999)}"
0
 DEFAULT_MASTER_NODE = "master@fuzed-dev.powerset.com"
0
 DEFAULT_REMOTE_RUBY = "http://fuzed-dev.powerset.com:9001/code"
0
-DEFAULT_ERLANG_CODEPATHS = %w[ebin/yaws ebin/eunit etest ebin/thrift ebin]
0
+DEFAULT_ERLANG_CODEPATHS = %w[ebin/yaws ebin/eunit etest ebint ebin]
0
 DEFAULT_BOOT_DIR = "/p/conf/fuzed/"
0
 
0
 def cookie_hash(node)
0
- Digest::MD5.hexdigest(node + "-powerset")
0
+ Digest::MD5.hexdigest(node + "-fuzed-changethis-btw-kkthx")
0
 end
0
 
0
 def rel(path)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
0
@@ -1 +1,92 @@
0
+-module(frontend_responder).
0
+-include("yaws_api.hrl").
0
+-include("yaws.hrl").
0
+-include("fuzed.hrl").
0
+-compile(export_all).
0
+
0
+out404(A, _GC, SC) ->
0
+ Parameters = {struct, parse_arg(A, SC)},
0
+ case node_api:safely_send_call_to_pool(handle_request,
0
+ Parameters,
0
+ {handle_request, {request}},
0
+ pure,
0
+ details()) of
0
+ {result, R} ->
0
+ convert_response(R);
0
+ {error, _R} ->
0
+ [{status, 500}, {html, "Sumpin fucked."}]
0
+ end.
0
+
0
+parse_arg(Request, ServerOptions) ->
0
+ Headers = Request#arg.headers,
0
+ {convert_method(Request),
0
+ convert_version(Request),
0
+ convert_querypath(Request),
0
+ {querydata, prep(Request#arg.querydata)},
0
+ {servername, prep(ServerOptions#sconf.servername)},
0
+ {headers, {struct, convert_headers(Request#arg.headers)}},
0
+ {cookies, {array, list_to_tuple(lists:map(fun(X) -> prep(X) end, Headers#headers.cookie))}},
0
+ {pathinfo, prep(ServerOptions#sconf.docroot)},
0
+ {postdata, Request#arg.clidata}}.
0
+
0
+
0
+convert_method(Request) ->
0
+ R = Request#arg.req,
0
+ {http_request,Method,{_Type,_Path},_} = R,
0
+ {method, Method}.
0
+
0
+convert_querypath(Request) ->
0
+ R = Request#arg.req,
0
+ {http_request,_Method,{_Type,Path},_} = R,
0
+ {querypath, prep(Path)}.
0
+
0
+convert_version(Request) ->
0
+ R = Request#arg.req,
0
+ {http_request,_Method,{_Type,_Path},Version} = R,
0
+ {http_version, Version}.
0
+
0
+convert_req(R) ->
0
+ {http_request,Method,{_Type,Path},_} = R,
0
+ {Method, prep(Path)}.
0
+
0
+convert_headers(A) ->
0
+ NormalHeaders = [{connection, prep(A#headers.connection)},
0
+ {accept, prep(A#headers.accept)},
0
+ {host, prep(A#headers.host)},
0
+ {if_modified_since, prep(A#headers.if_modified_since)},
0
+ {if_match, prep(A#headers.if_match)},
0
+ {if_none_match, prep(A#headers.if_none_match)},
0
+ {if_range, prep(A#headers.if_range)},
0
+ {if_unmodified_since, prep(A#headers.if_unmodified_since)},
0
+ {range, prep(A#headers.range)},
0
+ {referer, prep(A#headers.referer)},
0
+ {user_agent, prep(A#headers.user_agent)},
0
+ {accept_ranges, prep(A#headers.accept_ranges)},
0
+ {keep_alive, prep(A#headers.keep_alive)},
0
+ {location, prep(A#headers.location)},
0
+ {content_length, prep(A#headers.content_length)},
0
+ {content_type, prep(A#headers.content_type)},
0
+ {content_encoding, prep(A#headers.content_encoding)},
0
+ {authorization, prep(A#headers.authorization)},
0
+ {transfer_encoding, prep(A#headers.transfer_encoding)}],
0
+ SpecialHeaders =
0
+ lists:map(fun({http_header, _Len, Name, _, Value}) -> {prep(Name), prep(Value)} end,
0
+ A#headers.other),
0
+ list_to_tuple([{Name, Res} || {Name, Res} <- NormalHeaders, Res /= undefined] ++ SpecialHeaders).
0
+
0
+convert_response(EhtmlTuple) ->
0
+ {Status, AllHeaders, Html} = EhtmlTuple,
0
+ {allheaders, HeaderList} = AllHeaders,
0
+ ProcessedHeaderList = lists:map(fun({header, Name, Value}) -> {header, [binary_to_list(Name) ++ ":", binary_to_list(Value)]} end,
0
+ tuple_to_list(HeaderList)),
0
+ {html, RawResult} = Html,
0
+ [Status, {allheaders, ProcessedHeaderList}, {html, binary_to_list(RawResult)}].
0
+
0
+prep(A) when is_list(A) -> list_to_binary(A);
0
+prep(A) -> A.
0
+
0
+details() ->
0
+ {ok, Details} =
0
+ application:get_env(frontend, details),
0
+ Details.

Comments

    No one has commented yet.