Improve CORS implementation, add support for #976
Do no flush for long-polling