List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/1] ui-shared: Use CRLF in HTTP headers as per RFC 7230
@ 2016-05-11 17:48 wub
  2016-05-11 18:30 ` john
  2016-05-12 15:45 ` Jason
  0 siblings, 2 replies; 9+ messages in thread
From: wub @ 2016-05-11 17:48 UTC (permalink / raw)


CRLF is explicitly defined as the line break in the HTTP protocol
specifications: RFC 2616 (obsolete) and RFC 7230.
---
 ui-shared.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/ui-shared.c b/ui-shared.c
index 9a38aa9..b463375 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -672,36 +672,36 @@ void cgit_print_http_headers(void)
 		return;
 
 	if (ctx.page.status)
-		htmlf("Status: %d %s\n", ctx.page.status, ctx.page.statusmsg);
+		htmlf("Status: %d %s\r\n", ctx.page.status, ctx.page.statusmsg);
 	if (ctx.page.mimetype && ctx.page.charset)
-		htmlf("Content-Type: %s; charset=%s\n", ctx.page.mimetype,
+		htmlf("Content-Type: %s; charset=%s\r\n", ctx.page.mimetype,
 		      ctx.page.charset);
 	else if (ctx.page.mimetype)
-		htmlf("Content-Type: %s\n", ctx.page.mimetype);
+		htmlf("Content-Type: %s\r\n", ctx.page.mimetype);
 	if (ctx.page.size)
-		htmlf("Content-Length: %zd\n", ctx.page.size);
+		htmlf("Content-Length: %zd\r\n", ctx.page.size);
 	if (ctx.page.filename) {
 		html("Content-Disposition: inline; filename=\"");
 		html_header_arg_in_quotes(ctx.page.filename);
-		html("\"\n");
+		html("\"\r\n");
 	}
 	if (!ctx.env.authenticated)
-		html("Cache-Control: no-cache, no-store\n");
-	htmlf("Last-Modified: %s\n", http_date(ctx.page.modified));
-	htmlf("Expires: %s\n", http_date(ctx.page.expires));
+		html("Cache-Control: no-cache, no-store\r\n");
+	htmlf("Last-Modified: %s\r\n", http_date(ctx.page.modified));
+	htmlf("Expires: %s\r\n", http_date(ctx.page.expires));
 	if (ctx.page.etag)
-		htmlf("ETag: \"%s\"\n", ctx.page.etag);
-	html("\n");
+		htmlf("ETag: \"%s\"\r\n", ctx.page.etag);
+	html("\r\n");
 	if (ctx.env.request_method && !strcmp(ctx.env.request_method, "HEAD"))
 		exit(0);
 }
 
 void cgit_redirect(const char *url, bool permanent)
 {
-	htmlf("Status: %d %s\n", permanent ? 301 : 302, permanent ? "Moved" : "Found");
+	htmlf("Status: %d %s\r\n", permanent ? 301 : 302, permanent ? "Moved" : "Found");
 	html("Location: ");
 	html_url_path(url);
-	html("\n\n");
+	html("\r\n\r\n");
 }
 
 static void print_rel_vcs_link(const char *url)
-- 
2.8.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-05-12 15:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-11 17:48 [PATCH 1/1] ui-shared: Use CRLF in HTTP headers as per RFC 7230 wub
2016-05-11 18:30 ` john
2016-05-11 19:31   ` john
2016-05-11 19:38   ` wub
2016-05-11 19:57     ` john
2016-05-11 20:15       ` wub
2016-05-12 10:23         ` john
2016-05-12 15:45     ` Jason
2016-05-12 15:45 ` Jason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).