Description
I'm currently working with h11 v0.14.0 and python 3.10 and I'm attempting to monkeypatch the h11._headers.normalize_and_validate method to customize its behavior. However, I've encountered an issue where the native function always takes precedence, and my custom monkeypatch does not have any effect. I am trying to fix Transfer-Encoding headers issue: multiple Transfer-Encoding headers
What I've Tried:
I've successfully monkeypatched other methods, such as h11._headers.get_comma_header, with no issues.
Expected Behavior:
I expect to be able to monkeypatch the h11._headers.normalize_and_validate method and have my custom implementation take effect.
Actual Behavior:
The native h11._headers.normalize_and_validate method is always used, and my monkeypatch does not have any effect.
Sample:
WORKING:
import pytest
mp = pytest.MonkeyPatch()
def get_comma(headers, name):
print('some change')
...
mp.setattr("h11._headers.get_comma_header", get_comma)
I can successfully patch get_comma_header
NOT WORKING
import pytest
mp = pytest.MonkeyPatch()
def normalize(headers, _parsed=False):
print("Normalize")
...
mk.setattr("h11._headers.normalize_and_validate", normalize)
Cannot patch. Its still using the native method for this.