1%%%----------------------------------------------------------------------
2%%% File    : yaws_api.hrl
3%%% Author  : Claes Wikstrom <klacke@hyber.org>
4%%% Purpose :
5%%% Created : 24 Jan 2002 by Claes Wikstrom <klacke@hyber.org>
6%%%----------------------------------------------------------------------
7
8-author('klacke@hyber.org').
9
10-record(arg, {
11          clisock,        % the socket leading to the peer client
12          client_ip_port, % {ClientIp, ClientPort} tuple
13          headers,        % headers
14          req,            % request (possibly rewritten)
15          orig_req,       % original request
16          clidata,        % The client data (as a binary in POST requests)
17          server_path,    % The normalized server path
18                          % (pre-querystring part of URI)
19          querydata,      % For URIs of the form ...?querydata
20                          %  equiv of cgi QUERY_STRING
21          appmoddata,     % (deprecated - use pathinfo instead) the remainder
22                          % of the path leading up to the query
23          docroot,        % Physical base location of data for this request
24          docroot_mount,  % virtual directory e.g /myapp/ that the docroot
25                          %  refers to.
26          fullpath,       % full deep path to yaws file
27          cont,           % Continuation for chunked multipart uploads
28          state,          % State for use by users of the out/1 callback
29          pid,            % pid of the yaws worker process
30          opaque,         % useful to pass static data
31          appmod_prepath, % (deprecated - use prepath instead) path in front
32                          %  of: <appmod><appmoddata>
33          prepath,        % Path prior to 'dynamic' segment of URI.
34                          %  ie http://some.host/<prepath>/<script-point>/d/e
35                          % where <script-point> is an appmod mount point,
36                          % or .yaws,.php,.cgi,.fcgi etc script file.
37          pathinfo        % Set to '/d/e' when calling c.yaws for the request
38                          % http://some.host/a/b/c.yaws/d/e
39                          %  equiv of cgi PATH_INFO
40         }).
41
42
43-record(http_request, {method,
44                       path,
45                       version}).
46
47-record(http_response, {version,
48                        status,
49                        phrase}).
50
51-record(rewrite_response, {status,
52                           headers = [],
53                           content = <<>>}).
54
55-record(headers, {
56          connection,
57          accept,
58          host,
59          if_modified_since,
60          if_match,
61          if_none_match,
62          if_range,
63          if_unmodified_since,
64          range,
65          referer,
66          user_agent,
67          accept_ranges,
68          cookie = [],
69          keep_alive,
70          location,
71          content_length,
72          content_type,
73          content_encoding,
74          authorization,
75          transfer_encoding,
76          x_forwarded_for,
77          other = []   % misc other headers
78         }).
79
80
81
82
83-record(url,
84        {scheme,          % undefined means not set
85         host,            % undefined means not set
86         port,            % undefined means not set
87         path = [],
88         querypart = []}).
89
90
91-record(setcookie, {key,
92                    value,
93                    quoted = false,
94                    domain,
95                    max_age,
96                    expires,
97                    path,
98                    secure = false,
99                    http_only = false,
100                    extensions = []}).
101
102
103-record(cookie, {key,
104                 value,
105                 quoted = false}).
106
107
108-record(redir_self, {
109          host,        % string() - our own host
110          scheme,      % http | https
111          scheme_str,  % "https://"  | "http://"
112          port,        % integer()  - our own port
113          port_str     % "" | ":<int>" - the optional port part
114                       %                 to append to the url
115         }).
116
117%% Corresponds to the frame sections as in
118%% http://tools.ietf.org/html/rfc6455#section-5.2
119%% plus 'data' and 'ws_state'. Used for incoming frames.
120-record(ws_frame_info, {
121          fin,
122          rsv,
123          opcode,
124          masked,
125          masking_key,
126          length,
127          payload,
128          data,        % The unmasked payload. Makes payload redundant.
129          ws_state     % The ws_state after unframing this frame.
130                       % This is useful for the endpoint to know what type of
131                       % fragment a potentially fragmented message is.
132         }).
133
134%% Used for outgoing frames. No checks are done on the validity of a frame. This
135%% is the application's responsability to send valid frames.
136-record(ws_frame, {
137          fin = true,
138          rsv = 0,
139          opcode,
140          payload = <<>>
141         }).
142
143%%----------------------------------------------------------------------
144%% The state of a WebSocket connection.
145%% This is held by the ws owner process and passed in calls to yaws_api.
146%%----------------------------------------------------------------------
147-type frag_type() :: text
148                   | binary
149                   | none.  % The WebSocket is not expecting continuation
150                            % of any fragmented message.
151-record(ws_state, {
152          vsn :: integer(),                     % WebSocket version number
153          sock,                                 % gen_tcp or gen_ssl socket
154          frag_type :: frag_type()
155         }).
156