Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 106 lines (79 sloc) 3.162 kb
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
1
2 <erl>
3
7811247 @vinoski whitespace cleanup
vinoski authored
4 out(A) ->
20ece13 @klacke more css hackery
authored
5 {ssi, "TAB.inc", "%%",[{"arg", "choosen"}]}.
7811247 @vinoski whitespace cleanup
vinoski authored
6
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
7 </erl>
8
9 <div id="entry">
814eb04 @klacke ""
authored
10
11 <h2> The Arg </h2>
12
e35a591 @klacke more w3c compliance
authored
13 <p>This page displays the Arg #arg structure
14 supplied to the out/1 function.
15 </p>
7811247 @vinoski whitespace cleanup
vinoski authored
16 <p> The #arg structure is a very important datastructure for the
17 yaws programmer. It is the main mechanism whereby the server can pass
18 data to the web application. There are several data items
e35a591 @klacke more w3c compliance
authored
19 which are of interest to the webapplication, such as which headers
20 were sent from the client, etc.
21 The #arg recored is defined in <tt>yaws_api.hrl</tt> and is defined as:
22 </p>
23 <div class="box">
24 <pre>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
25
26
27 -record(arg, {
0be3c7e @klacke untabified all of yaws
authored
28 clisock, %% the socket leading to the peer client
29 client_ip_port, %% {Ip, Port} for the client
30 headers, %% headers
31 req, %% request
32 clidata, %% The client data (as a binary in POST requests)
33 server_path, %% The normalized server path
34 querydata, %% Was the URL on the form of ...?query (GET reqs)
35 appmoddata, %% the remainder of the path leading up to the query
36 docroot, %% where's the data
37 fullpath, %% full deep path to yaws file
38 cont, %% Continuation for chunked multipart uploads
39 state, %% State for use by users of the out/1 callback
40 pid, %% pid of the yaws worker process
41 opaque, %% useful to pass static data
42 appmod_prepath, %% path in front of: &lt;appmod&gt;&lt;appmoddata&gt;
43 pathinfo %% Set to 'd/e' when calling c.yaws for the request
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
44 %% http://some.host/a/b/c.yaws/d/e
7811247 @vinoski whitespace cleanup
vinoski authored
45 }).
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
46
e35a591 @klacke more w3c compliance
authored
47 </pre>
48 </div>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
49
7811247 @vinoski whitespace cleanup
vinoski authored
50 <p> As we have seen is several previous examples,
e35a591 @klacke more w3c compliance
authored
51 the <tt> out/1</tt> function
52 defined in .yaws files, gets invoked with a single argument which is
53 a #arg{} record, fitting the specific HTTP request being served.
54 </p>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
55
e35a591 @klacke more w3c compliance
authored
56 <p> The code to display the #arg{} record
a3b564d @klacke added the client IP address to the #arg record
authored
57 is in defined in file <a href="code.yaws?file=/arg2.yaws">arg2.yaws</a>
58 and is invoked at <a href="arg2.yaws">arg2.yaws</a>
e35a591 @klacke more w3c compliance
authored
59 </p>
b349dac @klacke ""
authored
60
814eb04 @klacke ""
authored
61 <erl>
62
63 out(A) ->
2026c22 @klacke ""
authored
64
a3b564d @klacke added the client IP address to the #arg record
authored
65 Peer = A#arg.client_ip_port,
814eb04 @klacke ""
authored
66 Req = A#arg.req,
67 H = yaws_api:reformat_header(A#arg.headers),
68 {ehtml,
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
69 [{h5,[], "The headers passed to us were:"},
757eca1 @klacke ""
authored
70 {hr,[],[]},
814eb04 @klacke ""
authored
71 {ol, [],lists:map(fun(S) -> {li,[], {p,[],S}} end,H)},
72
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
73 {h5, [], "The request"},
814eb04 @klacke ""
authored
74 {ul,[],
75 [{li,[], f("method: ~s", [Req#http_request.method])},
0be3c7e @klacke untabified all of yaws
authored
76 {li,[], f("path: ~p", [Req#http_request.path])},
77 {li,[], f("version: ~p", [Req#http_request.version])}]},
814eb04 @klacke ""
authored
78
757eca1 @klacke ""
authored
79 {hr,[],[]},
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
80 {h5, [], "Other items"},
814eb04 @klacke ""
authored
81 {ul,[],
a3b564d @klacke added the client IP address to the #arg record
authored
82 [{li, [], f("Peer: ~p", [Peer])},
0be3c7e @klacke untabified all of yaws
authored
83 {li,[], f("docroot: ~s", [A#arg.docroot])},
84 {li,[], f("fullpath: ~s", [A#arg.fullpath])}]},
757eca1 @klacke ""
authored
85 {hr,[],[]},
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
86 {h5, [], "Parsed query data"},
814eb04 @klacke ""
authored
87 {pre,[], f("~p", [yaws_api:parse_query(A)])},
757eca1 @klacke ""
authored
88 {hr,[],[]},
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
89 {h5,[], "Parsed POST data "},
814eb04 @klacke ""
authored
90 {pre,[], f("~p", [yaws_api:parse_post(A)])}]}.
91
92 </erl>
93
7811247 @vinoski whitespace cleanup
vinoski authored
94
95
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored
96
97
98 </div>
99
100
101 <erl>
102 out(A) -> {ssi, "END2",[],[]}.
103 </erl>
104
7811247 @vinoski whitespace cleanup
vinoski authored
105
Something went wrong with that request. Please try again.