[PATCH 1/1] ui-shared: Use CRLF in HTTP headers as per RFC 7230
Juuso Lapinlampi
wub at partyvan.eu
Wed May 11 19:48:51 CEST 2016
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
More information about the CGit
mailing list