Fixes the trailing header and refactors add_request_headers()