2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
11 /* ------------------------------------------------------------------------ */
15 * req.h: Request-specific data structures and functions
26 #include "base/pblock.h"
27 #include "base/session.h"
28 #include "frame/objset.h"
33 /* ------------------------------ Constants ------------------------------- */
36 #define REQ_HASHSIZE 10
37 #define REQ_MAX_LINE 4096
41 * The REQ_ return codes. These codes are used to determine what the server
42 * should do after a particular module completes its task.
44 * Func type functions return these as do many internal functions.
47 /* The function performed its task, proceed with the request */
49 /* The entire request should be aborted: An error occurred */
50 #define REQ_ABORTED -1
51 /* The function performed no task, but proceed anyway. */
52 #define REQ_NOACTION -2
53 /* Tear down the session and exit */
57 /* ------------------------------ Structures ------------------------------ */
61 /* Server working variables */
64 /* The method, URI, and protocol revision of this request */
66 /* Protocol specific headers */
70 /* Server's response headers */
73 /* The object set constructed to fulfill this request */
75 /* Array of objects that were created from .nsconfig files */
78 /* The stat last returned by request_stat_path */
84 /* SOCKS request data */
91 /* ------------------------------ Prototypes ------------------------------ */
95 * request_create creates a new request structure.
98 Request
*request_create();
101 * request_free destroys a request structure.
104 void request_free(Request
*req
);
108 * Restarts a request for a given URI internally. If rq is non-NULL, the
109 * function will keep the old request's headers and protocol, but with a new
110 * URI and method of GET. If the previous method was HEAD, this is preserved.
111 * Any other method becomes GET. You may assume that if you give it a request
112 * structure that it will use the same structure.
114 * Once you have this new Request, you must then do what you want with
115 * it (e.g. send the object back, perform uri2path translation, etc.)
118 Request
*request_restart_internal(char *uri
, Request
*rq
);
122 * request_translate_uri performs virtual to physical mapping on the given
123 * uri and returns either a path string or NULL depending on whether it was
127 char *request_translate_uri(char *uri
, Session
*sn
);
131 * request_header finds the named header depending on the requesting
132 * protocol. If possible, it will not load headers until the first is
133 * requested. You have to watch out because this can return REQ_ABORTED.
136 int request_header(char *name
, char **value
, Session
*sn
, Request
*rq
);
139 * request_loadheaders just makes sure the headers have been loaded.
142 int request_loadheaders(Session
*sn
, Request
*rq
);
146 * request_stat_path tries to stat path. If path is NULL, it will look in
147 * the vars pblock for "path". If the stat is successful, it returns the stat
148 * structure. If not, returns NULL and leaves a message in rq->staterr. If a
149 * previous call to this function was successful, and path is the same, the
150 * function will simply return the previously found value.
152 * User functions should not free this structure.
155 struct stat
*request_stat_path(char *path
, Request
*rq
);
159 * Parses the URI parameter in rq->vars and finds out what objects it
160 * references (using NameTrans). Builds the request's object set.
163 int request_uri2path(Session
*sn
, Request
*rq
);
166 * Performs any path checks needed for this request.
169 int request_pathchecks(Session
*sn
, Request
*rq
);
172 * Does all the ObjectType directives for a request
175 int request_fileinfo(Session
*sn
, Request
*rq
);
179 * request_handle_processed takes a Request structure with its reqpb
180 * block filled in and handles the request.
183 int request_handle_processed(Session
*sn
, Request
*rq
);
187 * Complete a request by finding the service function and using it. Returns
188 * REQ_NOACTION if no matching function was found.
191 int request_service(Session
*sn
, Request
*rq
);
195 * request_handle handles one request from the session's inbuf.
198 void request_handle(Session
*sn
);
201 * Moved here due to problems with interdependency. See object.h for
205 int object_findnext(Session
*sn
, Request
*rq
, httpd_object
*obj
);
206 int object_pathcheck(Session
*sn
, Request
*rq
, httpd_object
*obj
);
207 int object_findinfo(Session
*sn
, Request
*rq
, httpd_object
*obj
);
208 int object_findservice(Session
*sn
, Request
*rq
, httpd_object
*obj
);
209 int object_finderror(Session
*sn
, Request
*rq
, httpd_object
*obj
);
210 int object_findlogs(Session
*sn
, Request
*rq
, httpd_object
*obj
);