1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.http: add remote-addr header (#18208)

This commit is contained in:
xiusin 2023-05-21 21:23:24 +08:00 committed by GitHub
parent 38a155ac81
commit e4c769d072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,13 +100,17 @@ fn (mut s Server) parse_and_respond(mut conn net.TcpConn) {
reader.free()
}
}
req := parse_request(mut reader) or {
mut req := parse_request(mut reader) or {
$if debug {
// only show in debug mode to prevent abuse
eprintln('error parsing request: ${err}')
}
return
}
remote_ip := conn.peer_ip() or { '' }
req.header.add_custom('Remote-Addr', remote_ip) or {}
mut resp := s.handler.handle(req)
if resp.version() == .unknown {
resp.set_version(req.version)