move setting HTTP headers to a separate method

to make rubocop happy