title: update requests.session() header after each request
body: <p>I'm writing a python client for a RESTful API using <a href="https://2.python-requests.org/en/master/user/advanced/#session-objects" rel="nofollow noreferrer">requests.Session</a>. The API generates and returns a new CSRFToken after each request. The Devs of the API told me I need to update the session headers like so:</p>
  <pre><code>csrf = session.cookies.get('CSRFToken')
  session.headers.update({'x-csrf-token': csrf})
  </code></pre>
  <p>How can I bind this functionality at a Session object so that this functionality is automatically called after every request (maybe a nice inheritance sollution might be possible) so that it doesn't have to be called by the user after every request?</p>