Blame


1 9df487d7 2003-11-23 devnull #include <u.h>
2 9df487d7 2003-11-23 devnull #include <libc.h>
3 9df487d7 2003-11-23 devnull #include <bin.h>
4 9df487d7 2003-11-23 devnull #include <httpd.h>
5 9df487d7 2003-11-23 devnull
6 9df487d7 2003-11-23 devnull int
7 9df487d7 2003-11-23 devnull hunallowed(HConnect *c, char *allowed)
8 9df487d7 2003-11-23 devnull {
9 9df487d7 2003-11-23 devnull Hio *hout;
10 9df487d7 2003-11-23 devnull int n;
11 9df487d7 2003-11-23 devnull
12 9df487d7 2003-11-23 devnull n = snprint(c->xferbuf, HBufSize, "<head><title>Method Not Allowed</title></head>\r\n"
13 9df487d7 2003-11-23 devnull "<body><h1>Method Not Allowed</h1>\r\n"
14 9df487d7 2003-11-23 devnull "You can't %s on <a href=\"%U\"> here</a>.<p></body>\r\n", c->req.meth, c->req.uri);
15 9df487d7 2003-11-23 devnull
16 9df487d7 2003-11-23 devnull hout = &c->hout;
17 9df487d7 2003-11-23 devnull hprint(hout, "%s 405 Method Not Allowed\r\n", hversion);
18 9df487d7 2003-11-23 devnull hprint(hout, "Date: %D\r\n", time(nil));
19 9df487d7 2003-11-23 devnull hprint(hout, "Server: Plan9\r\n");
20 9df487d7 2003-11-23 devnull hprint(hout, "Content-Type: text/html\r\n");
21 9df487d7 2003-11-23 devnull hprint(hout, "Allow: %s\r\n", allowed);
22 9df487d7 2003-11-23 devnull hprint(hout, "Content-Length: %d\r\n", n);
23 9df487d7 2003-11-23 devnull if(c->head.closeit)
24 9df487d7 2003-11-23 devnull hprint(hout, "Connection: close\r\n");
25 9df487d7 2003-11-23 devnull else if(!http11(c))
26 9df487d7 2003-11-23 devnull hprint(hout, "Connection: Keep-Alive\r\n");
27 9df487d7 2003-11-23 devnull hprint(hout, "\r\n");
28 9df487d7 2003-11-23 devnull
29 9df487d7 2003-11-23 devnull if(strcmp(c->req.meth, "HEAD") != 0)
30 9df487d7 2003-11-23 devnull hwrite(hout, c->xferbuf, n);
31 9df487d7 2003-11-23 devnull
32 9df487d7 2003-11-23 devnull if(c->replog)
33 9df487d7 2003-11-23 devnull c->replog(c, "Reply: 405 Method Not Allowed\nReason: Method Not Allowed\n");
34 9df487d7 2003-11-23 devnull return hflush(hout);
35 9df487d7 2003-11-23 devnull }