Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Add RawTarget property to IHttpRequestFeature (#596) #639

Merged
merged 1 commit into from
May 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Microsoft.AspNetCore.Http.Features/IHttpRequestFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ public interface IHttpRequestFeature
/// </summary>
string QueryString { get; set; }

/// <summary>
/// The request target as it was sent in the HTTP request. This property contains the
/// raw path and full query, as well as other request targets such as * for OPTIONS
/// requests (https://tools.ietf.org/html/rfc7230#section-5.3).
/// </summary>
/// <remarks>
/// This property is not used internally for routing or authorization decisions. It has not
/// been UrlDecoded and care should be taken in its use.
/// </remarks>
string RawTarget { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RawTarget? Thats super cryptic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok in this case, it's not like we want people to use it. It's only the emergency backup.

That said, I'm sure @blowdart has some very strong language to put in the comments to the effect of Don't even think about using this, you won't do it right and then you'll get hacked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the technically correct term 😛

What about RawRequest? Or RawPath?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inaccurate.

Copy link
Member

@davidfowl davidfowl May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like RawPath, it's "hidden" already on the feature and people aren't stupid, let's not try to protect them.

Copy link
Contributor Author

@cesarblum cesarblum May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with RawPath is that it's incorrect. We'll include the query with it, not just the path. Plus the feature distinguishes between Path and PathBase, which makes it even more confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path is wrong, it's Path and Query at a minimum. And for things like Options * it's not Path or Query, it's just *. Target is the right term.

Copy link
Member

@davidfowl davidfowl May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call it RawTarget then, we'll be forever explaining this to people 😄 because the spec says so!

Copy link
Member

@Tratcher Tratcher May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what doc comments are for :-). Link to the RFC section.

Besides, most people don't even know what feature interfaces are.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh huh 😁


/// <summary>
/// Headers included in the request, aggregated by header name. The values are not split
/// or merged across header lines. E.g. The following headers:
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.AspNetCore.Http/Features/HttpRequestFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public HttpRequestFeature()
PathBase = string.Empty;
Path = string.Empty;
QueryString = string.Empty;
RawTarget = string.Empty;
}

public string Protocol { get; set; }
Expand All @@ -25,6 +26,7 @@ public HttpRequestFeature()
public string PathBase { get; set; }
public string Path { get; set; }
public string QueryString { get; set; }
public string RawTarget { get; set; }
public IHeaderDictionary Headers { get; set; }
public Stream Body { get; set; }
}
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.AspNetCore.Owin/OwinFeatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ string IHttpRequestFeature.QueryString
set { Prop(OwinConstants.RequestQueryString, Utilities.RemoveQuestionMark(value)); }
}

string IHttpRequestFeature.RawTarget
{
get { return string.Empty; }
set { throw new NotSupportedException(); }
}

IHeaderDictionary IHttpRequestFeature.Headers
{
get { return Utilities.MakeHeaderDictionary(Prop<IDictionary<string, string[]>>(OwinConstants.RequestHeaders)); }
Expand Down