Skip to content

Instantly share code, notes, and snippets.

@tanglebones
Created February 20, 2016 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanglebones/c0a6821e47dc469c6603 to your computer and use it in GitHub Desktop.
Save tanglebones/c0a6821e47dc469c6603 to your computer and use it in GitHub Desktop.
var webHeaderCollectionType = typeof(WebHeaderCollection);
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(webHeaderCollectionType.TypeHandle);
try
{
var hInfoFieldInfo = webHeaderCollectionType.GetField("HInfo", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Static);
var hInfo = hInfoFieldInfo.GetValue(null);
var hInfoType = hInfo.GetType().GetField("HeaderHashTable", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Static);
var hashtableOfHeaderInfos = hInfoType.GetValue(hInfo) as Hashtable;
foreach (var e in hashtableOfHeaderInfos.Values)
{
var headerIsRequestRestrictedFieldInfo = e.GetType().GetField("IsRequestRestricted", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
headerIsRequestRestrictedFieldInfo.SetValue(e, false);
var headerIsResponseRestrictedFieldInfo = e.GetType().GetField("IsResponseRestricted", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
headerIsResponseRestrictedFieldInfo.SetValue(e, false);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("total hack failed: " + ex);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment