diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-04 16:00:02 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-04 16:00:02 -0800 |
commit | df5e13809af0400a99c2a4e48c61f73043296119 (patch) | |
tree | acabeab122bf1f5abe973bca2252301ba6f315fa /src/DotNetOpenAuth.Core/Messaging | |
parent | bbb0214b9f41ad8bcd44eba3714b463eee29fe86 (diff) | |
download | DotNetOpenAuth-df5e13809af0400a99c2a4e48c61f73043296119.zip DotNetOpenAuth-df5e13809af0400a99c2a4e48c61f73043296119.tar.gz DotNetOpenAuth-df5e13809af0400a99c2a4e48c61f73043296119.tar.bz2 |
OpenIdOfflineProvider and RP now work together.
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging')
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs | 52 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs | 9 |
2 files changed, 59 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs index f3a1ba8..924a3c2 100644 --- a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs +++ b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs @@ -222,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"></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> diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs index 941187b..f561012 100644 --- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs @@ -1210,9 +1210,14 @@ namespace DotNetOpenAuth.Messaging { // even when set to their "original" values. foreach (string headerName in request.Headers) { switch (headerName) { - case "Accept": message.Headers.Accept.AddRange(request.AcceptTypes.Select(at => new MediaTypeWithQualityHeaderValue(at))); break; + case "Accept": message.Headers.Accept.AddRange(request.AcceptTypes.Select(at => new MediaTypeWithQualityHeaderValue(at.Trim()))); break; case "Connection": break; // Keep-Alive controls this - case "Content-Length": message.Content.Headers.ContentLength = request.ContentLength; break; + case "Content-Length": + if (!message.Content.Headers.ContentLength.HasValue) { + message.Content.Headers.ContentLength = request.ContentLength; + } + + break; case "Content-Type": message.Content.Headers.ContentType = new MediaTypeHeaderValue(request.ContentType); break; case "Expect": message.Headers.Expect.Add(new NameValueWithParametersHeaderValue(request.Headers[headerName])); break; case "Host": break; // implicitly copied as part of the RequestUri |