-
Notifications
You must be signed in to change notification settings - Fork 191
Add RawTarget property to IHttpRequestFeature (#596) #639
Conversation
a585486
to
be421c9
Compare
@@ -49,6 +49,11 @@ public interface IHttpRequestFeature | |||
string QueryString { get; set; } | |||
|
|||
/// <summary> | |||
/// The request target as it was sent in the HTTP request. | |||
/// </summary> | |||
string RawTarget { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RawTarget? Thats super cryptic
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inaccurate.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh huh 😁
Check Hosting's TestHost. |
So do I get a squirrel? |
I mean, I guess we have to wait for @blowdart's feedback on stating the new property should not be used unless someone really really really knows what they're doing. |
|
You still need more doc comments. An RFC section link and that the filed contains the escaped full path and/or query, or * for Options *. |
@@ -102,6 +102,12 @@ string IHttpRequestFeature.QueryString | |||
set { Prop(OwinConstants.RequestQueryString, Utilities.RemoveQuestionMark(value)); } | |||
} | |||
|
|||
string IHttpRequestFeature.RawTarget | |||
{ | |||
get { throw new NotSupportedException(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property Getters shouldn't throw, return string.Empty. Setters can throw.
Let's worry about it now. It's not just a docs issue, it's an xmldocs issue too. So how about /// This property is not used internally for routing or authorization decisions. It has not been UrlDecoded and care should be taken in its use. |
Updated. |
🚢 (I hate that squirrel) |
@@ -49,6 +49,15 @@ public interface IHttpRequestFeature | |||
string QueryString { get; set; } | |||
|
|||
/// <summary> | |||
/// The request target as it was sent in the HTTP request. This property contains the | |||
/// escaped path and full query, as well as other request targets such as * for OPTIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"escaped path"
Does this mean that the precent encoded characters in path are unescaped or raw? I think the word escaped implies that the server did some sort of escaping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was equally confused 😄 But "escaped" here means they are URL-encoded i.e. the %
s will be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use "raw" then
Turns out there was a bit more that I needed to change. @blowdart I've moved your warning on the property's usage to |
Yup :) |
|
a91444e
to
d778521
Compare
|
d778521
to
8a804a9
Compare
8a804a9
to
8212694
Compare
#596
Let me know if I'm missing anything on this repo.
Once this is merged I need to change:
Do you think
RawTarget
is a good name for the property? I didn't want to useUri
,Url
, or anything like that since this is called "target" in the RFCs.cc @Tratcher @halter73 @JunTaoLuo @blowdart @davidfowl