Ignore invalid response header in HttpClient, C#

I would like to use HttpClient to get files with bad but forgivable response headers. A suggestion has been made at Ignore invalid response header in HttpClient request #29927 to use socketsHandler.PlaintextStreamFilter.

To me, it seems easier to fork HttpClient and add a setting for useUnsafeHeaderParsing.

Would you please give a very basic example of how to remove or add headers using socketsHandler.PlaintextStreamFilter?


A classical use case for this would be creating a simple proxy server where you want to pass all the headers you have received, exactly as you have received them...

Example of a file with bad response header: https://publicadministration.un.org/egovkb/Portals/egovkb/Documents/un/2020-Survey/EgovSurvey2020_Ar.pdf

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum