diff options
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs')
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs index 75da833..ba1faab 100644 --- a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs +++ b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs @@ -9,17 +9,15 @@ namespace DotNetOpenAuth.Messaging { using System.Collections.Specialized; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Globalization; using System.IO; using System.Net; -#if CLR4 using System.Net.Http; using System.Net.Http.Headers; -#endif using System.Net.Mime; using System.ServiceModel.Channels; using System.Web; + using Validation; /// <summary> /// A property store of details of an incoming HTTP request. @@ -124,7 +122,6 @@ namespace DotNetOpenAuth.Messaging { Reporting.RecordRequestStatistics(this); } -#if CLR4 /// <summary> /// Initializes a new instance of the <see cref="HttpRequestInfo" /> class. /// </summary> @@ -144,7 +141,6 @@ namespace DotNetOpenAuth.Messaging { Reporting.RecordRequestStatistics(this); } -#endif /// <summary> /// Initializes a new instance of the <see cref="HttpRequestInfo"/> class. @@ -226,6 +222,58 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// When overridden in a derived class, gets an array of client-supported MIME accept types. + /// </summary> + /// <returns>An array of client-supported MIME accept types.</returns> + public override string[] AcceptTypes { + get { + if (this.Headers["Accept"] != null) { + return this.headers["Accept"].Split(','); + } + + return new string[0]; + } + } + + /// <summary> + /// When overridden in a derived class, gets information about the URL of the client request that linked to the current URL. + /// </summary> + /// <returns>The URL of the page that linked to the current request.</returns> + public override Uri UrlReferrer { + get { + if (this.Headers["Referer"] != null) { // misspelled word intentional, per RFC + return new Uri(this.Headers["Referer"]); + } + + return null; + } + } + + /// <summary> + /// When overridden in a derived class, gets the length, in bytes, of content that was sent by the client. + /// </summary> + /// <returns>The length, in bytes, of content that was sent by the client.</returns> + public override int ContentLength { + get { + if (this.Headers["Content-Length"] != null) { + return int.Parse(this.headers["Content-Length"]); + } + + return 0; + } + } + + /// <summary> + /// When overridden in a derived class, gets or sets the MIME content type of the request. + /// </summary> + /// <returns>The MIME content type of the request, such as "text/html".</returns> + /// <exception cref="System.NotImplementedException">Setter always throws</exception> + public override string ContentType { + get { return this.Headers["Content-Type"]; } + set { throw new NotImplementedException(); } + } + + /// <summary> /// Creates an <see cref="HttpRequestBase"/> instance that describes the specified HTTP request. /// </summary> /// <param name="request">The request.</param> @@ -309,7 +357,6 @@ namespace DotNetOpenAuth.Messaging { return new NameValueCollection(); } -#if CLR4 /// <summary> /// Adds HTTP headers to a <see cref="NameValueCollection"/>. /// </summary> @@ -325,6 +372,5 @@ namespace DotNetOpenAuth.Messaging { } } } -#endif } } |