Created
November 21, 2017 21:06
-
-
Save cbanner/5c96bb1143912a69a8f3c78666f10421 to your computer and use it in GitHub Desktop.
An extension method to ASP.NET Core's HttpRequest class, delivering the original request target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Http.Features; | |
/// <summary> | |
/// Gets the raw target of an HTTP request. | |
/// </summary> | |
/// <returns>Raw target of an HTTP request</returns> | |
/// <remarks> | |
/// ASP.NET Core manipulates the HTTP request parameters exposed to pipeline | |
/// components via the HttpRequest class. This extension method delivers an untainted | |
/// request target. https://tools.ietf.org/html/rfc7230#section-5.3 | |
/// </remarks> | |
public static string GetRawTarget(this HttpRequest request) | |
{ | |
var httpRequestFeature = request.HttpContext.Features.Get<IHttpRequestFeature>(); | |
return httpRequestFeature.RawTarget; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment