I am rendering a the header by using the Django Template engine which returns a django.utils.safestring.SafeString. When using this as a header I get the
requests.exceptions.InvalidHeader: Header part ('application/xml') from {'accept': 'application/xml'} must be of type str or bytes, not <class 'django.utils.safestring.SafeString'>
exception.
May be using a construct with isinstance(ret, tuple(HEADER_VALIDATORS)):
could solve the problem.
Hi, the validation of header type makes it impossible to use a str subclass.
code of validation: https://github.com/psf/requests/blob/ec553c275fe915ab8c179a530907b564892d2922/requests/utils.py#L1036
I am rendering a the header by using the Django Template engine which returns a django.utils.safestring.SafeString. When using this as a header I get the
requests.exceptions.InvalidHeader: Header part ('application/xml') from {'accept': 'application/xml'} must be of type str or bytes, not <class 'django.utils.safestring.SafeString'> exception.
May be using a construct with isinstance(ret, tuple(HEADER_VALIDATORS)): could solve the problem.
thx & br Matthias