List for cgit developers and users
 help / color / mirror / Atom feed
From: wub at partyvan.eu (Juuso Lapinlampi)
Subject: [PATCH 1/1] ui-shared: Use CRLF in HTTP headers as per RFC 7230
Date: Wed, 11 May 2016 17:48:51 +0000	[thread overview]
Message-ID: <1462988931-10035-1-git-send-email-wub@partyvan.eu> (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



             reply	other threads:[~2016-05-11 17:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 17:48 wub [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462988931-10035-1-git-send-email-wub@partyvan.eu \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).