1 /* Request processing thread.
2 * - by Richard W.M. Jones <rich@annexia.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * $Id: process_rq.h,v 1.7 2002/09/02 07:50:09 rich Exp $
24 #ifdef HAVE_SYS_SOCKET_H
25 #include <sys/socket.h>
32 #ifdef HAVE_SYS_STAT_H
38 #include <pthr_pseudothread.h>
39 #include <pthr_http.h>
40 #include <pthr_iolib.h>
42 /* The PROCESS_RQ type is both the pseudothread object which handles
43 * the request, and also the request information structure itself.
48 pseudothread pth; /* Pseudothread handle. */
49 pool pool; /* Thread pool for all allocations. */
50 int sock; /* Socket fd. */
51 io_handle io; /* IO handle. */
52 http_request http_request; /* HTTP request object. */
53 const char *host_header; /* Host header or "default". */
55 /* These are used to establish context by the cfg (configuration) code. */
56 void *host; /* Host object. */
57 void *alias; /* Alias object. */
59 /* The various different paths.
61 * REQUESTED_PATH is the path as requested by the user (sans query
62 * string). This path is grotty, containing ".", "..", "///", etc. Do
63 * not use it, except perhaps when displaying error messages.
65 * CANONICAL_PATH is the requested path cleaned up to remove ".", ".."
68 * REWRITTEN_PATH is the path after internal rewrite rules have been
71 * ALIASNAME is the alias which matches this path. REMAINDER is the
72 * remaining part of the path. Thus (in theory at least), ALIASNAME +
73 * REMAINDER == CANONICAL_PATH.
75 * ROOT is the document root corresponding to the matching alias. This
76 * corresponds to the actual path of the file on disk. FILE_PATH is
77 * the full path to the actual file on disk. Thus, ROOT + "/" + REMAINDER
80 * Directories are always followed by a "/". If a user requests a
81 * directory which isn't followed by a "/" then the path parsing code
82 * transparently issues a 301 (Permanently Moved) browser redirect
83 * including the corrected path.
85 * Example (no internal rewrite):
86 * REQUESTED_PATH "/cgi-bin/../docs/dir///file.html"
87 * CANONICAL_PATH "/docs/dir/file.html"
88 * REWRITTEN_PATH "/docs/dir/file.html"
90 * REMAINDER "dir/file.html"
91 * ROOT "/home/rich/mydocs"
92 * FILE_PATH "/home/rich/mydocs/dir/file.html"
94 * Example (with internal rewrite):
95 * REQUESTED_PATH "/cgi-bin/../docs/dir///file.html"
96 * CANONICAL_PATH "/docs/dir/file.html"
97 * REWRITTEN_PATH "/newdocs/dir/file.html"
98 * ALIASNAME "/newdocs/"
99 * REMAINDER "dir/file.html"
100 * ROOT "/home/rich/mynewdocs"
101 * FILE_PATH "/home/rich/mynewdocs/dir/file.html"
103 const char *requested_path;
104 const char *canonical_path;
105 const char *rewritten_path;
106 const char *aliasname;
107 const char *remainder;
109 const char *file_path;
111 struct stat statbuf; /* Stat of file. */
114 typedef struct process_rq *process_rq;
116 extern process_rq new_process_rq (int sock);
118 /* Define some RFC-compliant dates to represent past and future. */
119 #define DISTANT_PAST "Thu, 01 Dec 1994 16:00:00 GMT"
120 #define DISTANT_FUTURE "Sun, 01 Dec 2030 16:00:00 GMT"
122 /* Headers which are sent to defeat caches. */
123 #define NO_CACHE_HEADERS "Cache-Control", "must-revalidate", "Expires", DISTANT_PAST, "Pragma", "no-cache"
127 #endif /* PROCESS_RQ_H */