From: Mikko Rasa Date: Sun, 11 Dec 2022 16:26:02 +0000 (+0200) Subject: Fix processing of IPv6 addresses in HTTP server X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0cd8309240cd48fdc16d9cc433297e33a0a2cdd0;p=libs%2Fnet.git Fix processing of IPv6 addresses in HTTP server --- diff --git a/source/http/server.cpp b/source/http/server.cpp index 9c9a876..04bae0b 100644 --- a/source/http/server.cpp +++ b/source/http/server.cpp @@ -146,7 +146,7 @@ void Server::client_data_available(Client &cl) cl.request = make_unique(Request::parse(cl.in_buf)); string addr_str = cl.sock->get_peer_address().str(); - string::size_type colon = addr_str.find(':'); + string::size_type colon = addr_str.find(':', (addr_str[0]=='[' ? addr_str.find(']')+1 : 0)); cl.request->set_header("-Client-Host", addr_str.substr(0, colon)); if(cl.request->get_method()!="GET" && cl.request->get_method()!="POST")