blob: d0ebd6e27644ec357ae65dad43de846701226bc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.ComponentModel;
using System.ServiceModel.Security;
using System.Web.Http;
namespace System.Net.Http
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static class HttpRequestMessageExtensions
{
private const string SecurityKey = "Security";
/// <summary>
/// Gets the current <see cref="T:System.ServiceModel.Security.SecurityMessageProperty"/>
/// stored in <see cref="M:HttpRequestMessage.Properties"/> for the given request.
/// </summary>
/// <param name="request">The HTTP request.</param>
/// <returns>The <see cref="SecurityMessageProperty"/>.</returns>
public static SecurityMessageProperty GetSecurityMessageProperty(this HttpRequestMessage request)
{
if (request == null)
{
throw Error.ArgumentNull("request");
}
return request.GetProperty<SecurityMessageProperty>(SecurityKey);
}
private static T GetProperty<T>(this HttpRequestMessage request, string key)
{
T value;
request.Properties.TryGetValue(key, out value);
return value;
}
}
}
|