TS-2316: properly cherry-pick client header condition fix

This commit was cherry-picked with some errors:
    header_rewrite: fix for crash in client header condition