summary refs log tree commit diff
path: root/server.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/server.h b/server.h
index 0e77f7c..b1a22ee 100644
--- a/server.h
+++ b/server.h
@@ -121,6 +121,14 @@ httpHead(struct kreq *req, enum khttp http, enum kmime mime) {
 		|| khttp_head(req, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[mime]);
 }
 
+static inline enum kcgi_err
+httpRedirect(struct kreq *req, const char *url) {
+	return httpHead(req, KHTTP_302, KMIME_TEXT_PLAIN)
+		|| khttp_head(req, kresps[KRESP_LOCATION], "%s", url)
+		|| khttp_body(req)
+		|| khttp_printf(req, "%s\n", url);
+}
+
 static inline enum kcgi_err httpFail(struct kreq *req, enum khttp http) {
 	return httpHead(req, http, KMIME_TEXT_PLAIN)
 		|| khttp_body(req)