Conditional header rewrite with 'code' and 'when'

Based on unmerged contributions by Wallace Reis I added the option `when` for conditional rewriting of response headers.