Add Referer to GetTypedHeaders (#949)
* Add a Referer property * Add Uri to KnownParsers * Add property for Origin * Add Origin * Encode the URI From feedback from Tratcher * Inline the var 'out' declaration * Remove Origin Since it does not cleanly map to a Uri object since it can contain multiple values. * Took back that whitespace * Reverted * Add using for UriHelper.Encode
This commit is contained in:
parent
01b4530fa7
commit
75a7552360
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Http.Extensions;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Http.Headers
|
namespace Microsoft.AspNetCore.Http.Headers
|
||||||
|
|
@ -261,6 +262,23 @@ namespace Microsoft.AspNetCore.Http.Headers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Uri Referer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
Uri uri;
|
||||||
|
if (Uri.TryCreate(Headers[HeaderNames.Referer], UriKind.RelativeOrAbsolute, out uri))
|
||||||
|
{
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Headers.Set(HeaderNames.Referer, value == null ? null : UriHelper.Encode(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public T Get<T>(string name)
|
public T Get<T>(string name)
|
||||||
{
|
{
|
||||||
return Headers.Get<T>(name);
|
return Headers.Get<T>(name);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue