vdoc: improve simple HTTP support in serve_html
parent
8a6beac692
commit
db05e5b66c
|
@ -162,8 +162,9 @@ fn (mut cfg DocConfig) serve_html() {
|
||||||
url := urllib.parse(data[1]) or { return }
|
url := urllib.parse(data[1]) or { return }
|
||||||
filename = if url.path == '/' { def_name } else { url.path.trim_left('/') }
|
filename = if url.path == '/' { def_name } else { url.path.trim_left('/') }
|
||||||
}
|
}
|
||||||
html := docs[filename]
|
html := docs[filename].trim_space()
|
||||||
con.write('HTTP/1.1 200 OK\r\nContent-Type: $content_type\r\n\r\n$html') or {
|
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 }
|
con.close() or { return }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue