vdoc: add http connection read/write timeouts (fix #7343)
parent
e40e1500a8
commit
a4d3a0575a
|
@ -175,6 +175,8 @@ fn (mut cfg DocConfig) serve_html() {
|
||||||
server.close() or { }
|
server.close() or { }
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
conn.set_read_timeout(5 * time.second)
|
||||||
|
conn.set_write_timeout(5 * time.second)
|
||||||
handle_http_connection(mut conn, server_context)
|
handle_http_connection(mut conn, server_context)
|
||||||
conn.close() or { eprintln('error closing the connection: $err') }
|
conn.close() or { eprintln('error closing the connection: $err') }
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,11 @@ fn (mut r BufferedReader) fill_buffer() ? {
|
||||||
// from the upstream reader so that we dont have to keep
|
// from the upstream reader so that we dont have to keep
|
||||||
// trying to call this
|
// trying to call this
|
||||||
r.offset = 0
|
r.offset = 0
|
||||||
r.len = r.reader.read(mut r.buf) or {
|
new_len := r.reader.read(mut r.buf) or {
|
||||||
|
eprintln('>> BufferedReader.reader.read err: $err')
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
r.len = new_len
|
||||||
}
|
}
|
||||||
|
|
||||||
// read_line reads a line from the buffered reader
|
// read_line reads a line from the buffered reader
|
||||||
|
@ -93,3 +95,4 @@ pub fn (mut r BufferedReader) read_line() ?string {
|
||||||
r.offset = i
|
r.offset = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue