Erlang Programming/Creating Web Applications with yaws/Arg structure

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The arg data structure is the main mechanism which the server uses to forward essential information to the web application. The #arg record is defined in yaws_api.hrl and is defined as:

-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
         }).

Some of the parameters in the Arg structure contain additional information as shown below.

-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
         }).