forked from Sustainsys/Saml2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpRequestBaseExtensions.cs
36 lines (34 loc) · 1.28 KB
/
HttpRequestBaseExtensions.cs
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
using Kentor.AuthServices.WebSso;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Kentor.AuthServices.HttpModule
{
/// <summary>
/// Static class that hold extension methods for <see cref="HttpRequestBase"/>.
/// </summary>
public static class HttpRequestBaseExtensions
{
/// <summary>
/// Extension method to convert a HttpRequestBase to a HttpRequestData.
/// </summary>
/// <param name="requestBase">The request object used to populate the <c>HttpRequestData</c>.</param>
/// <returns>The <c>HttpRequestData</c> object that has been populated by the request.</returns>
public static HttpRequestData ToHttpRequestData(this HttpRequestBase requestBase)
{
if (requestBase == null)
{
throw new ArgumentNullException("requestBase");
}
return new HttpRequestData(
requestBase.HttpMethod,
requestBase.Url,
requestBase.ApplicationPath,
requestBase.Form.Cast<string>().Select((de, i) =>
new KeyValuePair<string, string[]>(de, ((string)requestBase.Form[i]).Split(','))));
}
}
}