I believe that the problem was closing the socket too fast, before OS
could finish its IO; that resulted in TCP Reset (RST) instead of FIN,
and browser showed connection error.
This change implements a graceful shutdown, by closing the sending
half, then using an expiring wait for the peer's ACK/FIN. I suppose
that 5 s timeout is reasonable for local operations.
In fact, I wasn't able to reproduce the problem after commit id
I16efa58ba90b98e71b13a0081dcdcc9d660db0b6 (tdf#101630: Make local
HTTP server cross-platform, using boost/beast); but it could be only
because of HW performance, and I hope the change follows "best
practices".
Change-Id: Ic3e9cf4e841d254197129ea7905527e97cae481a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201715
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 40a71882e983ac28782293cc036479e405e66a1c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201821
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>