3 * This file is part of httpd.
5 * 02/17/1996 Michael Temari <Michael@TemWare.Com>
6 * 07/07/1996 Initial Relase Michael Temari <Michael@TemWare.Com>
7 * 12/29/2002 Michael Temari <Michael@TemWare.Com>
8 * 05/14/2006 Michael Temari <Michael@TemWare.Com>
11 #include <sys/types.h>
26 int processrequest(rq
, rp
)
27 struct http_request
*rq
;
28 struct http_reply
*rp
;
30 /* clear out http_reply */
31 memset(rp
, 0, sizeof(*rp
));
32 rp
->status
= HTTP_STATUS_OK
;
33 strcpy(rp
->statusmsg
, "OK");
34 rp
->modtime
= (time_t) -1;
41 if(Redirect
!= NULL
) {
42 rp
->status
= HTTP_STATUS_MOVED_PERM
;
43 strcpy(rp
->realurl
, Redirect
);
44 strcat(rp
->realurl
, rq
->uri
);
45 strcpy(rq
->url
, rp
->realurl
);
49 /* Simple requests can only be a GET */
50 if(rq
->type
== HTTP_REQUEST_TYPE_SIMPLE
&& rq
->method
!= HTTP_METHOD_GET
) {
51 rp
->status
= HTTP_STATUS_BAD_REQUEST
;
52 strcpy(rp
->statusmsg
, "Bad request");
56 /* I don't know this method */
57 if(rq
->method
== HTTP_METHOD_UNKNOWN
) {
58 rp
->status
= HTTP_STATUS_NOT_IMPLEMENTED
;
59 strcpy(rp
->statusmsg
, "Method not implemented");
63 /* Check for access and real location of url */
67 /* We're done if there was an error accessing the url */
68 if(rp
->status
!= HTTP_STATUS_OK
)
71 /* Check to see if we have a newer version for them */
72 if(rq
->method
== HTTP_METHOD_GET
)
73 if(rq
->ifmodsince
!= (time_t) -1)
74 if(rq
->ifmodsince
< time((time_t *)NULL
))
75 if(rp
->modtime
!= (time_t) -1 && rp
->modtime
<= rq
->ifmodsince
) {
76 rp
->status
= HTTP_STATUS_NOT_MODIFIED
;
77 strcpy(rp
->statusmsg
, "Not modified");
83 rp
->status
= HTTP_STATUS_OK
;
84 strcpy(rp
->statusmsg
, "OK");
87 rp
->keepopen
= rq
->keepopen
;