7 hredirected(HConnect *c, char *how, char *uri)
16 }else if(uri[0] != '/'){
17 s = strrchr(c->req.uri, '/');
20 ss = halloc(c, strlen(c->req.uri) + strlen(uri) + 2 + UTFmax);
21 sprint(ss, "%s/%s", c->req.uri, uri);
27 n = snprint(c->xferbuf, HBufSize,
28 "<head><title>Redirection</title></head>\r\n"
29 "<body><h1>Redirection</h1>\r\n"
30 "Your selection can be found <a href=\"%U\"> here</a>.<p></body>\r\n", uri);
33 hprint(hout, "%s %s\r\n", hversion, how);
34 hprint(hout, "Date: %D\r\n", time(nil));
35 hprint(hout, "Server: Plan9\r\n");
36 hprint(hout, "Content-type: text/html\r\n");
37 hprint(hout, "Content-Length: %d\r\n", n);
38 if(host == nil || host[0] == 0)
39 hprint(hout, "Location: %U\r\n", uri);
41 hprint(hout, "Location: http://%U%U\r\n", host, uri);
43 hprint(hout, "Connection: close\r\n");
45 hprint(hout, "Connection: Keep-Alive\r\n");
48 if(strcmp(c->req.meth, "HEAD") != 0)
49 hwrite(hout, c->xferbuf, n);
52 if(host == nil || host[0] == 0)
53 c->replog(c, "Reply: %s\nRedirect: %U\n", how, uri);
55 c->replog(c, "Reply: %s\nRedirect: http://%U%U\n", how, host, uri);
61 hmoved(HConnect *c, char *uri)
63 return hredirected(c, "301 Moved Permanently", uri);