Catch error on write to closed socket caused by HEAD request