Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

106 lines (79 sloc) 3.17 KB
out(A) ->
{ssi, "", "%%",[{"arg", "choosen"}]}.
<div id="entry">
<h2> The Arg </h2>
<p>This page displays the Arg #arg structure
supplied to the out/1 function.
<p> The #arg structure is a very important datastructure for the
yaws programmer. It is the main mechanism whereby the server can pass
data to the web application. There are several data items
which are of interest to the webapplication, such as which headers
were sent from the client, etc.
The #arg recored is defined in <tt>yaws_api.hrl</tt> and is defined as:
<div class="box">
-record(arg, {
clisock, %% the socket leading to the peer client
client_ip_port, %% {Ip, Port} for the client
headers, %% headers
req, %% request
clidata, %% The client data (as a binary in POST requests)
server_path, %% The normalized server path
querydata, %% Was the URL on the form of ...?query (GET reqs)
appmoddata, %% the remainder of the path leading up to the query
docroot, %% where's the data
fullpath, %% full deep path to yaws file
cont, %% Continuation for chunked multipart uploads
state, %% State for use by users of the out/1 callback
pid, %% pid of the yaws worker process
opaque, %% useful to pass static data
appmod_prepath, %% path in front of: &lt;appmod&gt;&lt;appmoddata&gt;
pathinfo %% Set to 'd/e' when calling c.yaws for the request
<p> As we have seen is several previous examples,
the <tt> out/1</tt> function
defined in .yaws files, gets invoked with a single argument which is
a #arg{} record, fitting the specific HTTP request being served.
<p> The code to display the #arg{} record
is in defined in file <a href="code.yaws?file=/arg2.yaws">arg2.yaws</a>
and is invoked at <a href="arg2.yaws">arg2.yaws</a>
out(A) ->
Peer = A#arg.client_ip_port,
Req = A#arg.req,
H = yaws_api:reformat_header(A#arg.headers),
[{h5,[], "The headers passed to us were:"},
{ol, [],lists:map(fun(S) -> {li,[], {p,[],S}} end,H)},
{h5, [], "The request"},
[{li,[], f("method: ~s", [Req#http_request.method])},
{li,[], f("path: ~p", [Req#http_request.path])},
{li,[], f("version: ~p", [Req#http_request.version])}]},
{h5, [], "Other items"},
[{li, [], f("Peer: ~p", [Peer])},
{li,[], f("docroot: ~s", [A#arg.docroot])},
{li,[], f("fullpath: ~s", [A#arg.fullpath])}]},
{h5, [], "Parsed query data"},
{pre,[], f("~p", [yaws_api:parse_query(A)])},
{h5,[], "Parsed POST data "},
{pre,[], f("~p", [yaws_api:parse_post(A)])}]}.
out(A) -> {ssi, "END2",[],[]}.
Jump to Line
Something went wrong with that request. Please try again.