You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
What are you really trying to do?
It's probably a local import somewhere that would need to be monkeypatched
instead, but this isn't really a supported interface...
On Wed, Oct 11, 2023, 12:23 Dragan Dimoski ***@***.***> wrote:
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.
—
Reply to this email directly, view it on GitHub
<#167>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEU42EFI3C54OUPWRKODZTX63W3BANCNFSM6AAAAAA54PTGJM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
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:
I can successfully patch
get_comma_header
NOT WORKING
Cannot patch. Its still using the native method for this.
The text was updated successfully, but these errors were encountered: