From db05e5b66c23ff9337ee9be8c13974e60c1b8fbb Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 20 Jun 2020 20:37:46 +0300 Subject: [PATCH] vdoc: improve simple HTTP support in serve_html --- cmd/tools/vdoc.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vdoc.v b/cmd/tools/vdoc.v index cbde014ad3..2aaf1ccb82 100644 --- a/cmd/tools/vdoc.v +++ b/cmd/tools/vdoc.v @@ -162,8 +162,9 @@ fn (mut cfg DocConfig) serve_html() { url := urllib.parse(data[1]) or { return } filename = if url.path == '/' { def_name } else { url.path.trim_left('/') } } - html := docs[filename] - con.write('HTTP/1.1 200 OK\r\nContent-Type: $content_type\r\n\r\n$html') or { + html := docs[filename].trim_space() + content_length := html.len + con.send_string('HTTP/1.1 200 OK\r\nServer: VDoc\r\nContent-Type: ${content_type}\r\nContent-Length: ${content_length}\r\nConnection: close\r\n\r\n${html}') or { con.close() or { return } return }