Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.

Commit 1993a13

Browse files
author
Adam Hathcock
committed
Add flag to stop always checking the form body for the override flag
1 parent 70b7861 commit 1993a13

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/Nancy/Request.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,13 @@ private void RewriteMethod()
307307
var overrides =
308308
new List<Tuple<string, string>>
309309
{
310-
Tuple.Create("_method form input element", (string)this.Form["_method"]),
311-
Tuple.Create("X-HTTP-Method-Override form input element", (string)this.Form["X-HTTP-Method-Override"]),
312310
Tuple.Create("X-HTTP-Method-Override header", this.Headers["X-HTTP-Method-Override"].FirstOrDefault())
313311
};
312+
if (!StaticConfiguration.DisableXHttpMethodOverrideBodyDiscovery)
313+
{
314+
overrides.Add(Tuple.Create("_method form input element", (string)this.Form["_method"]));
315+
overrides.Add(Tuple.Create("X-HTTP-Method-Override form input element", (string)this.Form["X-HTTP-Method-Override"]));
316+
}
314317

315318
var providedOverride =
316319
overrides.Where(x => !string.IsNullOrEmpty(x.Item2))

src/Nancy/StaticConfiguration.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public static bool DisableErrorTraces
5555
[Description("Enables explicit HEAD routing and disables the usage of GET routes for HEAD requests.")]
5656
public static bool EnableHeadRouting { get; set; }
5757

58+
/// <summary>
59+
/// Gets or sets a value indicating whether or not to disable the discovery of the X-HTTP-Method-Override flag in a request body.
60+
/// This can be in the headers or posted form body of a request. This flag will disable the discovery of this
61+
/// flag in the body of a request to avoid buffering the request body.
62+
/// </summary>
63+
[Description("Gets or sets a value indicating whether or not to disable the discovery of the X-HTTP-Method-Override flag in a request body.")]
64+
public static bool DisableXHttpMethodOverrideBodyDiscovery { get; set; }
65+
5866
/// <summary>
5967
/// Gets a value indicating whether we are running in debug mode or not.
6068
/// Checks the entry assembly to see whether it has been built in debug mode.

0 commit comments

Comments
 (0)