Erlang 程式設計/使用 yaws 建立 Web 應用程式/Arg 結構
外觀
Arg 資料結構是伺服器用來向 Web 應用程式轉發基本資訊的主要機制。在yaws_api.hrl 中定義 #arg 記錄,定義如下
-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: <appmod><appmoddata>
pathinfo %% Set to 'd/e' when calling c.yaws for the request
%% http://some.host/a/b/c.yaws/d/e
}).
Arg 結構中的一些引數包含其他資訊,如下所示。
-record(headers, {
connection,
accept,
host,
if_modified_since,
if_match,
if_none_match,
if_range,
if_unmodified_since,
range,
referer,
user_agent,
accept_ranges,
cookie = [],
keep_alive,
content_length,
authorization,
other = [] %% misc other headers
}).