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>
10 #include <sys/types.h>
25 int processrequest(rq
, rp
)
26 struct http_request
*rq
;
27 struct http_reply
*rp
;
29 /* clear out http_reply */
30 memset(rp
, 0, sizeof(*rp
));
31 rp
->status
= HTTP_STATUS_OK
;
32 strcpy(rp
->statusmsg
, "OK");
33 rp
->modtime
= (time_t) -1;
40 /* Simple requests can only be a GET */
41 if(rq
->type
== HTTP_REQUEST_TYPE_SIMPLE
&& rq
->method
!= HTTP_METHOD_GET
) {
42 rp
->status
= HTTP_STATUS_BAD_REQUEST
;
43 strcpy(rp
->statusmsg
, "Bad request");
47 /* I don't know this method */
48 if(rq
->method
== HTTP_METHOD_UNKNOWN
) {
49 rp
->status
= HTTP_STATUS_NOT_IMPLEMENTED
;
50 strcpy(rp
->statusmsg
, "Method not implemented");
54 /* Check for access and real location of url */
58 /* We're done if there was an error accessing the url */
59 if(rp
->status
!= HTTP_STATUS_OK
)
62 /* Check to see if we have a newer version for them */
63 if(rq
->method
== HTTP_METHOD_GET
)
64 if(rq
->ifmodsince
!= (time_t) -1)
65 if(rq
->ifmodsince
< time((time_t *)NULL
))
66 if(rp
->modtime
!= (time_t) -1 && rp
->modtime
<= rq
->ifmodsince
) {
67 rp
->status
= HTTP_STATUS_NOT_MODIFIED
;
68 strcpy(rp
->statusmsg
, "Not modified");
74 rp
->status
= HTTP_STATUS_OK
;
75 strcpy(rp
->statusmsg
, "OK");
78 rp
->keepopen
= rq
->keepopen
;