LPS-39339 Fix performance and functional issues in http response header ...

...sanitizing